How can I modify the hosts file on MacOS Catalina? I need to test out a site before it's actually live for customers, and doing so with a specific hostname. For this I'd like to modify the well-known hosts file, however it doesnt seem to work.

An answer here mentions to do a copy of the file and modify, and then paste it back to the original /etc/hosts location. I've tried it but doesnt work.

I've tried the guide here too, with restarting the DNS services (sudo killall -HUP mDNSResponder) on my computer. Doesnt work either. I've made a complete reboot too, to no avail.

Have Apple prevented people in MacOS Catalina (10.15.X and later) to modify this file? It seems a lot of people are having problem with this. 

Thanks for your help!

Update: To clarify: I can successfully change the hosts file and save it, but it seems to have no effect.
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.