I don’t think this is actually what the OP had in mind, but *Redshirts *by John Scalzi is a novel about characters in a TV show who realize they are TV characters and set out to change their fates.
Hmmm… IIRC actually Deadpool and Cable kind of do this in the Facebook Avengers Alliance game. I seem to recall a team up fight with them and at the end there’s some dialogue where Deadpool makes references to them being in a video game and Cable says something like “I thought you said we were in a comic book.”
In a series 3, possibly series 4, episode of the BBC sitcom “Coupling” one of the characters yells at another “Because this is not an American sitcom!” This is funny because very shortly before that, the US version of the show, on NBC, had been canceled after only four aired episodes. So they were acknowledging the existence(and in fact the demise) of the US media property, while not acknowledging they were, in fact, part of the ongoing BBC media property.
Enjoy,
Steven
Abed on Community does this. He did it quite a bit in the first season. When the plot revolved around an old trope, Abed would point it out and say something like “oh, we’re doing the ______________ thing. Cool.” The others think he’s crazy for it.
In later seasons Abed doesn’t do this near as much, but every once in a while he still acknowledged their fictional universe as a sly wink to the audience.
In Galaxy Quest, Sam Rockwell breaks the TV fourth wall a lot, even though he’s really a movie character.
He actually did it fairly frequently. In later seasons, he had a television in his den, and he would watch the action of the other characters. It was a great inversion, he was watching the show that he was in. He would then comment to the audience – for example, that he could put a stop to the plot mix-up, but then they would be ending the show too early.