Yes, it is possible using the following steps. Replace "mynewhostname" with whatever hostname you are changing to.
1) First change the hostname read on bootup, to make the change permanent.
echo "mynewhostname" | sudo tee /etc/hostname
2) Edit the hosts-file so that the new name can be resolved.
Replace the line 127.0.01.1 raspberrypi
(raspberrypi
being the old hostname) with 127.0.01.1 mynewhostname
.
sudo nano /etc/hosts
3) Change the currently used hostname.
This is the trick to skip rebooting, issue the following command to change the currently used hostname:
sudo hostnamectl set-hostname "mynewhostname"
4) Restart the mDNS daemon
To be able to use mynewhostname.local
from other machines, we need to restart the mDNS daemon to respond to the new hostname.
sudo systemctl restart avahi-daemon