On jailbroken iPhones, you can do it by installing a tweak called BlowToUnlock, which, as its name indicates, allows you to wake up your phone (not unlock it, though, if you have set it to require a passphrase or fingerprint to be unlocked) by blowing air into the primary microphone.
I once...