A Clockwork Orange (1971)
Director - Stanley Kubrick
Alex (Malcolm McDowell) breaks into a happy song as he and his "droogs" perform a bit of "ultra-violence" and rape. Reportedly Kubrick filmed this scene several times and wasn't happy with it each time - until he told McDowell to just "do anything he wanted".
McDowell decided to belt out "Singing in the Rain" and Kubrick was so pleased with how much better the scene became that he acquired the rights to use the song immediately.