To change the hostname on you Linux server you can follow any of the below methods:
hostnamectl set-hostname <hostname>
nmtui is a great utility which can help you not oly change the hostname but changing other network management properties like editing a connection configuration and enabling and disabling it.
Also you can edit /etc/sysconfig/network and add the following:
hostname = put_name_here
Restart the hostname daemon to confirm and check current status
systemctl restart systemd-hostnamed
Tip: changing hostname on AWS Linux instance
In aws there is an installed package called cloud-init which is responsible for the initialization of cloud instance, you need to edit that file and add the following parameter at the end of the file.