If the agent hostname is changed after the agent was installed and registered to a manager. Reboot the agent machine and it will register using the new hostname.
Historical logs will be in the management interface under the old hostname, you can remove this if you don't need to keep the logs.
If during the agent install the agent was added with a name that is not the hostname, then it is registered to the manager under that name. If you change the hostname of that machine it will not affect the name on the manager. You can continue to use the same name after the hostname update in the management interface.