Simply follow these steps.
1. Open the terminal (ctrl+alt+t) and enter the following command
sudo nano /etc/hostname
you 'll be asked to input your password, after that the hostname file will open in nano editor. Now, you just have to replace your current hostname with the new one. hit ctrl+o to save and ctrl+x to exit nano editor.
2. Enter the following command to open the /etc/hosts file
sudo nano /etc/hosts
now, again find your current hostname and replace it with the new name then save and exit.