If it didn't originate with the show, Law & Order (the original run) has the line: "You could get a ham sandwich indicted" was said to Jack McCoy in one episode. I think I remember it coming up again in another episode.
Law & Order often takes from reality. The ham sandwich phrase is attributed to Solomon Wachter who was a judge on the New York court of Appeals and is anecdotally dated to the mid or late '80s. And then went widely into the culture and has shown up in novels, academic papers, and tv.
You _used_ to be able to indict a ham sandwich anyway. These days the federal government can’t even manage to indict someone caught on video throwing a hand sandwich at law enforcement.
Solomon "Sol" Wachtler appears to have coined the phrase.
He is a retired New York judge, ultimately chief judge of the New York Court of Appeals.
And still living at 96.
<https://en.wikipedia.org/wiki/Sol_Wachtler>