Install dnsmasq using Homebrew. Edit the dnsmasq.conf file (Homebrew will tell you where to put it) to contain:
address=/.dev/127.0.0.1
listen-address=127.0.0.1
Then make sure Dnsmasq is running (again follow Homebrew instructions).
Create the /etc/resolver/dev directory (using root) if it doesn't exist yet and create a resolver for .dev: