In the stage version of West Side Story, Maria sings "I Feel Pretty" after the rumble scene, and before she finds out Tony killed her brother, and "Gee, Officer Krupke" is also sang after the death of Riff. Both songs were moved to before the rumble in the movie version.
Cabaret introduces its upbeat title song immediately following a scene where one of the main characters gets beaten up by Nazis.
The opening number, "Willkommen," evolves into this song. At the top of the show, the Emcee sings "Welcome, stranger — happy to see you, stay!" in 3 languages, all chirpy and everything, while the girls on stage entice the men in the audience, apparently enjoying the spectacle just as much as the Emcee is. This lasts until the very last version of the song — in which the girls are jaded, low-energy, bruised and beaten, their clothing torn, and the Emcee has become practically malevolent. It's a commentary on the "mask of normalcy" people are wearing during the Nazi occupation, and if you know it's coming, it makes the song a lot less chirpily cheerful during the opening.
Another example from Cabaret is "Tomorrow Belongs to Me", the upbeat opener sung by a bunch of young people about how the future's going to be great. Then you realize it's being sung by the Hitler Youth...
Done better on stage than the movie. The stage version is a slow, sweet tune; in the production I saw it was sung by an honest to god countertenor. I didn't know the show then, and it was a serious WHAM moment when the "waiters" turned to reveal swastika armbands as they marched off.
Most of the score of Sweeney Todd: The Demon Barber of Fleet Street, whether it's the "Johanna Sequence", where Sweeney sings a tender ballad of paternal love as he slits throats, "God, That's Good", wherein Mrs. Lovett, Toby, and a slew of "satisfied" customers sing about how great the meat pies are, or "A Little Priest," a cheery waltz about Mrs. Lovett's... ideas.
The "Johanna Sequence" is an odd example, given that Sweeney's lines are about how he doesn't really care what happens to his daughter anymore — a song about how he's basically losing his humanity while he murders people isn't quite as strange. The song/action combination is still dissonant, though.
It's not that Sweeney doesn't care about Johanna any more, it's more that he's growing resigned to the fact that he can never be her father... almost a lament for the fact that he's lost her. So not too dissonant really...
Adding onto the fact that he feels it would be too painful to love, or even see her, because she would remind him too much of Lucy.
Urinetown: The Musical features a few of these, including
Snuff That Girl a cheerful number about how the resistance is going to get captured eventually, so they might as well off the Big Bad's daughter and have some fun. (Fitting, as it's a parody of the gang songs of West Side Story.)
But even more ironic is the Finale, I See A River. It begins as a cheerful song about the triumph of the poor, until Officer Lockstock comes on stage and reveals that by removing the restrictions on restroom use, the towns water reserves have been exhausted, thus dooming everyone to die of thirst. Shortly after this revelation, the song transitions into the Recurring Riff from the first number of the show.
This trope even has a lampshade hung on it by Officer Lockstock and Little Sally in one scene. Lockstock says something to the effect of "This is not a Happy Musical" to which Little Sally responds "But the music is so happy!".
In the second act of Hair, the cast members act out increasingly violent situations in which everyone is "killed." Afterwards two cast members sing a peppy musical version of Shakespeare's "What a piece of work is a man" speech over the stage strewn with dead bodies.
In Vanities: A New Musical (Pasadena Playhouse and ACT versions), the finale ultimo song "Letting Go" is sung during/immediately after Mary's mother's funeral.
In the final act of Jez Butterworth's Jerusalem, a sexually abused May Queen orders ex-daredevil and local bad influence Rooster Byron to dance with her. They get interrupted by her stepfather and brothers, who beat Rooster to a pulp inside his trailer, brand him with a poker, and leave him bleeding on the floor. All this is set to Fairport Convention's wistful "Who Knows Where the Time Goes?"
The finale of the original London production of Miss Saigon had mournful music playing over the scene as Kim prepares to say goodbye to her son Tam. This abruptly segues into a reprise of the raucous, upbeat song "American Dream", which culminates in the sound of a gunshot—Kim has fatally wounded herself.