This gist is based off the fedoramagazine article about NetworkManager's dnsmasq plugin
$ cat /etc/NetworkManager/conf.d/00-use-dnsmasq.conf
# Enables the dnsmasq plugin.
[main]
dns=dnsmasq
$ cat /etc/NetworkManager/dnsmasq.d/00-dot-test.conf
# Resolve all *.test domains to localhost
address=/.test/127.0.0.1
$ cat /etc/NetworkManager/dnsmasq.d/01-use-etc-hosts.conf
# By default, the dnsmasq plugin does not read from /etc/hosts.
# This forces the plugin to slurp in the file.
#
# If you do not want to write to the /etc/hosts file, you can simply specify another one.
addn-hosts=/etc/hosts
systemctl restart NetworkManager.service