Unable to set the hostname in RockyLinux?

Sometimes what you might also have to do, is edit /etc/cloud/cloud.cfg and make sure this value is set:

preserve_hostname: true

as on reboot cloud-init can run and reset your hostname again - the config file will probably already have an entry so you can search for it and edit the existing value and change from false to true. A lot of VPS/instance providers are using cloud-init. By setting that value, it stops cloud-init from resetting the hostname, meaning what you set before with hostnamectl, etc will not get overwritten/reset.