How can I modify the hosts file on MacOS Catalina?
So it actually did work.
What I did wrong (it seems) is that I had too many spaces between the ip and the hostname inside /etc/hosts. I fixed the spaces with the nano editor and now it works.
It's worth to point out that using nslookup will not work however to test your dns change (found reason here):

nslookup only does proper DNS resolution, which is significantly
different from the Name Service Switch subsystem that your other
applications use; that is to say nslookup ignores /etc/hosts and mDNS.