Applescript to set the mac's DNS to the selected Pi-hole IP if on specified wifi network and if it responds to ping.
Use it from within Automator as an app which you can run anytime or combine it with Hammerspoon (http://www.hammerspoon.org/) to run everytime the mac wakes up.