That is an issue with sudo and not Pi-hole.
If setup a Linux host properly without Pi-hole, your suppose to provide the own hostname in both the /etc/hostname & /etc/hosts files anyway like you did.
That would have probably fixed your sudo issue.
The /etc/hosts file has precedence over DNS name resolution meaning a ping, curl or netcat will first look at the hosts file before forwarding an A or AAAA query to a DNS server.
Thats not hacking, thats the only proper way or a variant of it (I use 127.0.1.1 to the same effect):
pi@ph5b:~ $ cat /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.1.1 ph5b.home.dehakkelaar.nl ph5b