I tried to remove the immutable permission of hosts file with "sudo chattr -i /etc/hosts" command but it is not changing. Can anyone please help me with this.

I tried to forcefully write the file with :wq! In vim still the file is not changed
>Solution :
I think, you can solve this problem using:
sudo chattr -ai /etc/hosts
Hope this helps!