Older Than Feudalism: Terence does this twice in his The Girl from Andros. In ancient Roman theater, the stage was always an outside (a street, a square), so if you wanted to tell the audience something happened in-doors, the people on the stage (outside) would have to comment on something happening inside the house, sometimes by speaking to people unseen, supposedly still inside the house. In addition, in many comedies pregnant women would give birth very quickly and very easily (sorta like Instant Birth, Just Add Water). In the play, the protagonist Simo comments on both these thingsnote SIMO: "Even this, who is there that knows you that would not believe that it originated in you?" DAVUS: "Why, what is this?" SIMO: "She didn't order in their presence what was requisite to be done for the woman lying in; but after she has come out, she bawls from the street to those who are in the house. O Davus, am I thus trifled with by you? Or pray, do I seem to you so very well suited to be thus openly imposed upon by your tricks? At all events it should have been with pre-caution; that at least I might have seemed to be feared, if I should detect it.", citing them as proof he is being scammed to believe Glycerium is pregnent with his grandson.
Fabian: If this were play'd upon a stage now, I could condemn it as an improbable fiction.
Most of the Sweet Polly Olivers tend to lampshade the fact that in those times that a boy is playing a female character that is disguising herself as a boy.
Hamlet's "Speak the speech I pray you" monologue can be seen as a combination of putting a shade on the common Theater techniques of the era, and a Take That against the overuse of it.
The prologue of Henry V, quite possibly the purest example of this trope, where the Chorus calls to attention the fact that a stage could never represent a battlefield, then tries to inspire the audiences imagination so that it doesn't matter anyway.
This gets positively recursive in the 1989 movie version as the Chorus speaks the prologue on a classical Shakespearean stage, but then throws the on-set doors open; the audience is then led into the movie proper, a period-accurate reproduction complete with epic battle sequences.
The entire closing monologue to As You Like It, where Shakespeare comments on the low quality of the play, the oddness of the main female character speaking the epilogue, the idea that a good epilogue might improve a play, and that the "woman" saying the lines was played by a man, making "her" part in the play that of a man playing a woman playing a man. Slightly earlier the characters also comment on the deus ex machina (which is even more convoluted than a normal example) which wrapped everything up in just a couple pages with a brand new character coming out of nowhere.
The fact that the entire thing's been a play is also commented upon in the epilogues for both A Midsummer Night's Dream and The Tempest. The former also has quite a few lampshades hung surrounding the acting of the players at the end.
In Henry VI Part 3, things are going badly for the Yorkists at the Battle of Towton. The leaders gather and exchange poetic speeches about how badly it's going, that being how characters do things in these plays. Warwick reproves them thusly:
Why stand we like soft-hearted women here,
Wailing our losses, whiles the foe doth rage;
And look upon, as if the tragedy
Were play'd in jest by counterfeiting actors?
In Spamalot, the Broadway adaptation of Monty Python and the Holy Grail, Sir Galahad and The Lady of the Lake sing "The Song That Goes Like This." Every phrase lampshades tropes of show tunes, love songs in particular.
Furthermore, Sir Robin, when discussing the glamour and beauty of Broadway, dashes King Arthur's dreams of being in a Broadway musical by explaining "You won't succeed on Broadway if you don't have any Jews!" This, being England in the middle of the Crusades, is not likely — what Jew will come out to a heavily armed Christian? The Lady of the Lake resolves this quandary for Arthur by telling him, "You're in a Broadway musical!" as the lights around the stage sparkle. Finally, addressing one of many anachronisms, when Sir Lancelot and Herbert are wed, Lancelot pinches his beloved's cheek and says to him, "Just think, Herbert, in a thousand years' time this will still be controversial."
The great sorceror Tim. Stage direction calls for the strings holding him up to be visible from the back of the theater. King Arthur loudly states his amazement that Tim is flying without any method of support whatsoever.
The Phantom of the Opera: "You'd never get away / With all this in a play / But if it's loudly sung / And in a foreign tongue / It's just the sort of story / Audiences adore / In fact, a perfect opera!"
There's a classic moment when one character, who is allegedly an intelligent and erudite theater critic, starts talking about how a character in a play who is supposed to be intelligent does something really stupid. You see, in that play, the allegedly smart guy was in a house with a bunch of murderers, and he doesn't try to leave. He doesn't even have the sense to be scared! Instead, he sits down in a chair and stops paying attention, while one of the murderers sneaks up behind him and ties him up with the curtain cord! Meanwhile, the theater critic, who also happens to be in a house full of murderers and not at all concerned about this, sits down in a chair, and one of the murderers sneaks up behind him and ties him up with, you guessed it, the curtain cord!
There's also a gag about one of the characters looking uncannily like Boris Karloff. Guess who played that character in the original production?