To set or change the hostname on Ubuntu 26.04, use hostnamectl and update /etc/hosts.
Step 1 : Show the current hostname.

Step 2 : Set a new name.

Step 3 : Confirm the file.

Step 4 : Update /etc/hosts.

Step 5 : Reboot.

You have set or changed the hostname on Ubuntu 26.04.