My totally made up guess is when we sleep our brains operate at a lower temperature than awake, regardless of activity. So to quickly transition from waking temperature to sleeping temperature, maybe yawning does a rapid cooling that's then maintained by normal slower-acting processes.