I cloned an Ubuntu 18.04 Server instance post which I wished to change the hostname of the new instance. What was supposed to be a simple operation of updating the hostname in the /etc/hostname and running sudo hostname <new hostname> didn't work as expected. The hostname used to revert on reboot. It took me quite some time to arrive at the right solution. An Ask Ubuntu answer set me in the right direction though it did not work as-is. The reason is the shipment of cloud-init in Ubuntu 18.04. I got it to work with the following steps -
Edit the cloud.cfg file present in /etc/cloud to set preserve_hostname to true.
Edit the /etc/hostname file and set the desired hostname in it.
Use hostnamectl to set the hostname. The new name would persist on reboots.