To change a hostname in Oracle Linux 9, use nmcli to set the new hostname, then reboot and verify the change. Alternatively, the hostnamectl utility can also be used for this task.