The only connections between the two are that they come from the same album, and that they loosely involve ham and eggs. Properly, the punch line is that "the chicken was involved, but the pig was committed."
Both contextually followed a joke in which Sammy Davis Jr. approached Gregory for advice because he was thinking of converting to Judaism. Greg's response was "Don't go -- what you want to be segregated *twice* for?"
By the way, nice history of that joke pltrygyst, I wasn't familiar with Gregory.
And I do think Bill Maher probably did nothing to try and hide the fact that it wasn't his joke. Adams on the other hand is portraying PHB as trying to take credit. Saying Maher's name in the same sentence as Adams' isn't exactly fair by the way ;-). YMMV.
I didn't see this as "stealing a joke"...at least not where he's trying to take credit. I think the saying is well known enough, and he's just portraying the PHB as spewing cliches and idioms. The originality comes when Wally responds to this now cliched joke, turned training material...."If I work like a dead pig.....". Wally is twisting the simile to his advantage, in order to mock it.