An issue of Uncanny X-Men from 1975 has the speech ("To sleep, perchance to dream.") in its opening narration.
The bard of Avon said it best: "To sleep, perchance to dream...Aye, there's the rub! For in that sleep of death, what dreams may come when we have shuffled off this mortal coil, must give us pause." And if the dreams of the dead must give us pause...what then of the dreams of the living? For example, the dreams of Charles Xavier?
Clouseau: Cato, something is rotten in the state of Denmark!
Clouseau: Yes, that too.
Musical Hair uses "What a piece of work is a man" for song lyrics.
In the sixth movie of Star Trek, The Undiscovered Country, with the famous quote that to truly appreciate Shakespeare, you need to hear it "in the original Klingon."
The Princess Diaries: The second movie has Lilly referring to Mia's chambermaids as 'Rosencrantz' and 'Guildenstern'.
True Romance: "Something is rotten in the state of Denmark."
Gettysburg: Hamlet's "What a piece of work is man" speech is said by a fictionalized version of Joshua Chamberlain.
At the end of Revenge of the Sith, the late Padme Amidala is actually laid out in a similar way to how Ophelia died by drowning for her funeral in Naboo after she has been strangled to death by her own husband Anakin Skywalker Darth Vader due to him completely falling to the Dark Side.
The chairman of Apocalypse, Inc. says "Neither a borrower nor a lender be" in The Toxic Avenger Part II.
"To thine own self be true" was used by Heather in Clueless
While Wyrd Sisters is most obviously Macbeth as noted below, the Ghost of the Murdered King seeking revenge, and the idea of guilting the Duke with a play that duplicates the events of the murder are both straight from Hamlet.
The book The 13 Clocks has its hero quote Nanki-Poo, thereby also quoting Shakespeare. Nanki-Poo's famous song in The Mikado, the line "A thing of shreds and patches" echoes Hamlet's line, "A king of shreds and patches.".y.
"How all occasions do inform against me" comes up often in Blackout/All Clear by Connie Willis, they might as well be Arc Words. Polly Churchill chooses all her aliases from Shakespeare, and she falls in with a famous Shakespearean actor who constantly speaks in allusions to the Bard.
Live Action TV
Arrested Development: "Well, it's like the Ten Commandments say. 'Be true to thine ownself, and to thine own self..." "Be true. Yeah. Number seven."
Frank Burns uses the line "Neither a borrower nor a lender be" (rather inaptly) to Radar.
Winchester, at the end of the "Dreams" episode. "To sleep, perchance to dream." Thus encouraging everyone to get another cup of coffee.
The Mighty Boosh: Howard offers death-related quotes, and at one point the 'Death, the undiscovered country' soliloquy.
Murdoch Mysteries: The Coroner Dr Julia Ogden is examining a skull and quotes "I knew him, Horatio" and laughs heartily at her little joke. Detective Murdoch and Constable Crabtree are rather disturbed by her morgue sense of humour.
"Opheliac" quotes a big part of Hamlet in "Doubt thou the stars are fire/Doubt thou the sun doth move/Doubt truth to be a liar/But never doubt I love." But then, the song is basically a tribute to Hamlet's Ophelia, so this was to be expected.
"Goodnight Sweet Ladies" takes its name from a quote from Ophelia.
The Major from the Hellsing Ultimate OVA quotes Hamlet, although instead of saying "there are more things in heaven and earth than are dreamt of in your philosophy" he says "there are more things in heaven and hell then are dreamt of in their philosophy"
Ned Martin, a radio announcer for baseball's Boston Red Sox in the 1960s and '70s, was fond of using Claudius' "O Gertrude, when sorrows come, they come not single spies but in battalions" when things went bad for the team.
In Ruddigore, Robin quotes "Alas, poor ghost!" Also, his faithful servant Adam is named after a similar character in As You Like It.
In "Show Me" from My Fair Lady, Liza interrupts Freddie's romantic song verse with "Words! Words! Words! I'm so sick of words!" Reference to "Words, words, words".
In Nanki-Poo's famous song in The Mikado, the line "A thing of shreds and patches" echoes Hamlet's line, "A king of shreds and patches."
There are a ton of references to Hamlet in the Marathon trilogy. Marathon 2 has a level entitled "The Slings & Arrows of Outrageous Fortune". Marathon Infinity has a level called "Poor Yorick". In the level "Rise Robot Rise", Tycho compares Durandal and himself, respectively, to Claudius and Hamlet, "only I'm not crazy".
In Mass Effect, there are references to an all-elcor production of Hamlet on the Citadel. The elcor are an alien race who express emotions in ways that are undetectable to humans, such as pheromones and extremely subtle visual cues. The director states that the idea behind an all-elcor cast was to challenge the audience by stripping out all the emotional subtext and leaving the audience to judge the characters on the merits of their actions alone.
Lisa uses Hamlet to explain the concept of "a play within a play" and Nested Story. She figures "a video tape of you watching TV" would be more successful.
There was a version of Hamlet in on of those trilogy stories, with Bart as Hamlet, Homer as dead king, Moe was Claudius and Marge was Gertrude. Carl and Lenny were of course Rosen-Carl and Gilden-Lenny. Lisa had a brief scene as crazy Ophelia.
Before an operation, Captain Queenan tells Collin that "readiness is all."
Costigan quotes Hawthorne. Dignam isn't impressed: [fart noise] "What's the matter, smartass, you don't know any fuckin' Shakespeare?"
Eric from Morecambe and Wise decided to do Hamlet's soliloquy because drama makes more money than comedy. After Ernie interrupting him, he eventually starts: "To be or not to be. That is the question. ... Thank you." He bows and leaves. Ernies then explains that there's more to it than that, so Eric goes back to doing comedy (after the skull comments that the entire thing was rubbish).
"To thine own self be true" was said in Renaissance Man by Bill.
An exchange on Salute Your Shorts is inspired by Hamlet's observation that "a man may fish with the worm that hath eat of a king, and eat of the fish that hath fed of that worm" and therefore that "a king may go a progress through the guts of a beggar."
Pinsky: Think about it. When you die they stick you in the ground and it's the worms that eat you up!
Z.Z.: Then somebody digs up the worms that ate you and use to catch fish which somebody else eats.
Donkeylips: So wait a second guys, when we had fish sticks the other night, I could have eaten a fish, that ate a worm, that ate Elvis?
Z.Z.: You could be burping up the King as we speak!