Probably the latter. Star Trek seems to like this joke; Chekov claimed many things as "invented in Russia," Spock attributes Sherlock Holmes quotes and Richard Nixon quotes to ancient Vulcans (though the Sherlock thing could be real, I suppose, since Spock is also half human), Quark claims the phrase "discretion is the better part of valor" as a Ferengi proverb, and Khan says "Revenge is a dish best served cold" is a Klingon saying. I think it was just one point on the line of a running gag. (a running gagh?)
Interestingly, the line became a problem in the shooting of The Undiscovered Country, as Mark Okrand (who invented the Klingon language) recounts:
There is one line of Shakespeare that is spoken in Klingon in the film, though it wasn’t part of the original script. That line is “To be or not to be.” When the film’s director, Nick Meyer, asked me to create a Klingon version of that, I said “okay,” but I thought “oh, no.” The problem was that there is no verb in Klingon that means “to be,” and I make a big deal about that in the book. I thought a bit and asked Nick if the line could mean “to live or not to live.” [But Christopher Plummer didn't like it, so] I thought some more, and suggested that taH replace yIn: taH pagh taHbe’. [...] The syllable taH, up until that moment, had been a suffix meaning “to continue doing” whatever the verb it was attached to was, so “eat” plus taH meant “to continue eating.” I sort of gave it a promotion to full verb status, but keeping the same meaning. So a new word meaning “to go on, to continue, to endure,” was created: “To continue or not to continue, to go on or not to go on.”