A: Follow these steps.
1.) Login to your EC2 instance and execute the commands below.
2.) sudo hostnamectl set-hostname "yourhostname"
"yourhostname" will be whatever you want to call it.
Remove the quotation marks.
For example: sudo hostnamectl set-hostname myserver
will create a hostname called myserver
3.) sudo vi /etc/cloud/cloud.cfg
4.) At the end of file add the following line and save the file
preserve_hostname: true
5.) Reboot the server with sudo -i
6.) After the server is back up type in hostname and your new hostname will show