Via brew or other method
In order to work on every connection and on any TLD, dnsmasq needs to be the first DNS resolver receving the query.
And since dnsmasq is a local process, all DNS queries need to go to 127.0.0.1
On macOS, /etc/resolv.conf is automaticaly created, depending on a variety of things (network settings, etc), so it cannot be edited.