This is the rule ( actually 1 of 2 as you have to make separate UDP TCP rules for it to work ) I've created for exactly the same reason ; to block any hardcoded DNS resolvers from being used via the WAN interface instead of my pihole located in my LAN .
https://imgur.com/lNJtDXw >> Just make sure your pihole's IP is outside of the Source IP Address Range as otherwise it won't be able to make upstream DNS querries to your chosen upstream DNS resolver . (I have my pihole set up with a manual IP outside the usual 100-254 DHCP pool range of IPs)
I'm not sure why I can't block every public/outside IP and can only go only as high as you can see but that was the limitation in my EU firmware (I got to that value by trial & error going back in increments ); I'm not really worried though as most of the major DNS resolvers out there (Google , Cloudflare , IBM Quad9 , OpenDNS , etc. ) are within that range so they're blocked (in theory there might be an app or two who could reach some specific DNS resolver but for the vast majority my pihole is the sole resolver they can connect to )