Force host to use alternate DNS servers on unresolvable queries with dnsmasq
Assuming that dnsmasq runs on the IOT device:
Your approach cannot work. As soon as a mobile phone is connected to a WiFi, it assumes that this wifi has an internet connection. But as you say, your IOT device / WLAN has no internet connection, so any attempt to reach an alternative DNS would fail.
The solution to your problem would be to simply configure your phone not to use this WiFi (or configure the Wifi not to accept connections from mobile phones) - as far as I know, a phone does not have the option "use the mobile data connection" while a WiFi is connected. And nothing you configure in your dnsmasq server would be able to change that...