I have met the "fruit sniffing" dog several times and am aware (from watching Border Security) of currency-sniffing and firearms-sniffing dogs in addition to the classic drug-sniffers. Generally, these dogs sniff people's bags more than people. (The Canadian beagle that met my flight from the Caribbean once sat [the dog's signal] about my bag, but the handler didn't even want to look in the pocket when I said there was no fruit in it. The Australian german shepherd didn't sit and the handler was not interested in looking to confirm when I said there was peppermint gum in the pocket the dog smelled at the most.)
[As an aside, in addition to being more interested in bags than people, the vast majority of these dogs work Arrivals not Departures and are found in the baggage hall. The chances of someone being sniffed on their way to a plane are very low. Still, since you worry about this, let me also add that they should allow plenty of time to get to the plane so that unexpected stop-and-search moments don't result in them being paged to get to the gate and almost missing the plane. I found a 6 minute video that specifically shows cash dogs working in Departures at Heathrow. Watch it and you will hear the handlers tell people "let the dog sniff your bags" (not you) and see that the dogs do not touch the people. You can also see people putting backpacks and other worn-high bags such as purses down towards the ground to let them be sniffed.]
My recommendation to you (and it helps other things as well) is to have your pockets as empty as possible. In my case that means completely empty. Everything, even my boarding pass, money, and cellphone, is in my carry on bag. Make sure that none of your bags [carryon or checked] contain fruit, meat, drugs, thousands of dollars in bank notes, guns, or illicit drugs of course.
Also, have a quick chat with your imam to clarify the difference between going over to someone's home and patting their dog and generally deliberately interacting with a dog vs being in a public place where a working dog approaches you, sniffs you without touching you, and then leaves. The public is not supposed to pat or interact with the sniffer dogs and the dog is not supposed to touch you at all. This conversation may reduce your anxiety about airport dogs a little, which is a good thing, because anxiety in an airport always gets you extra attention. Your imam may also advise you about the washing that is required after a dog has licked (unlikely with a trained professional) or nuzzled you or your possessions. If you need to bring something specific to clean up from the dog contact, have it with you in your carryon, in a size and format that won't cause issues going through security.
Finally if the dog approaches you, put your bag down, stand up, step back from your bag, and hold your arms out a bit - partly to make yourself bigger and partly so your hands are up and away from the dog. Look at the handler, not the dog, and say "please don't let the dog touch me" - the handler should understand that request and be fine with it.