What are some of the pettiest things a filmmaker has ever done in (one of) their films?
It could be an inclusion done by a director, writer or producer, doesn't matter that much, as long as the pettiness is on full display in the film.
Two famous examples:
Roland Emmerich had characters mocking critics Roger Ebert and Gene Siskel added in Godzilla (1998) after the two had criticized some of his earlier films. The characters on-screen are the useless mayor Ebert and his assistant Gene, the latter giving mayor Ebert two thumbs down at the end of the movie. The real life Ebert and Siskel were not impressed, neither by the movie nor their parodies.
Bob Fosse's semi-autobiographical All That Jazz (1979) starring Roy Scheider as Bob Fosse stand-in Joe Gideon features a rival Broadway/film director played by John Lithgow. While it was never confirmed who this character was based on, rumours suggest Fosse's Broadway rivals Harold Prince or Michael Bennett, or some amalgamation of the two. Regardless, in a non-pivotal scene Lithgow's character Lucas Sergeant is approached by a fan (much to his ego's excitement), when the fan says:
'Could I have your autograph? I'm an actress, too. You're my favorite director after Joe Gideon. I'm so sorry your show was a flop.'