Hello David,
What type of distribution are you running? The hostname is set via DHCP exit hook (
/etc/dhcp/dhclient-exit-hooks) and will be re-configured to match the instance name anytime the network is brought up. More details can be found
here. Host name is based off the client name which comes from the metadata server.
However, you may try the following in the startup-script from "custom metadata" of your instance :
1. Select the VM instance and then click Edit button
2. In the custom metadata field, enter the following:
Key: hostname
Value: $HOSTNAME
3. Then click save.
Please let me know of the result.