Snakes cannot really cough but if you're sure the sound came from his mouth, it sounds like he might have been trying to barf up something. On the other hand, some
keepers have been royally surprised when their BP farts loudly, so maybe that's what you heard, but why his mouth was open? only your snake knows for sure. Maybe
he was trying to scream out a warning to you...? Seriously, I'd keep an eye on him...hopefully nothing's wrong. Maybe he drank water & it "went down wrong"?