Ken Levine has a post up about stunt casting and the experience of writing and shooting a Johnny Carson guest shot on Cheers. (He'd done very brief guest appearances on "Newhart," "Night Court" and -- unseen -- "Mary Tyler Moore" -- but this was probably his longest guest appearance since the inevitable "Here's Lucy" appearance.)
I think my favorite kind of stunt cameo is where the celebrity is cast as someone other than himself, and the joke is the absurdity of seeing this person playing a character he or she would never play under normal circumstances. I'm not talking here about having a celebrity play an actual character in the story, complete with learning his or her lines, rehearsing, etc.; I'm talking about very brief walk-on appearances where the casting is the whole joke. Paul Henning was one writer/showrunner who liked to do this sometimes, as in this bit from "The Beverly Hillbillies."