Excel♥Saga has Excel and Hyatt repeatedly try to do this. It doesn't work right. Even when they disguise the bomb as a giant panda.
In Cowboy Bebop, Gren sets Vicious up the bomb in the form of a music box.
In Irresponsible Captain Tylor, Tylor gives a present to the enemy captain he has just surrendered to, not knowing that it was actually a bomb the space marines on board had given to him wrapped as a gift to get rid of him, making this a totally unintentional instance of Somebody Set Up Us the Bomb.
There's a running gag of Team Rocket getting stuck with some really undesirable mon-related situation, such as being surrounded by Gyarados. Sometimes, this is a Voltorb that proceeds to, you guessed it, self-destruct.
The New Pride leaves a bomb for the Runaways in a red herring trap.
Major Bludd leaves a bomb for both sides of a business deal in an issue of the Devil's Due version of G.I.Joe.
The original Stargate movie had O'Neil sending a nuclear warhead up to Ra's spaceship.
Even better, Ra's soldiers were going to use that bomb to do the same to Earth, and after killing them, O'Neil sent it to Ra because he couldn't deactivate it.
Star Trek: Generations. Captain Picard is fiddling with the control panel for Soran's sun-killer missile. When Soran orders him away from it and goes to work on it himself, he discovers that Picard has sabotaged the missile. As the launch clock counts down to zero, the last we see of Soran is the look of despair on his face as the missile explodes, killing him.
Star Trek III: The Search for Spock. After some Klingons beam over to the Enterprise in order to capture it, they hear the computer counting down the last few seconds before the ship's Self-Destruct Mechanism activates. Their leader, Kruge, is listening in and tells them to get out, but it's too late.
Alt-Captain Janeway (or maybe the original? It's a bit confusing) pulls the same trick in "Deadlock." The Vidiians, having overrun Voyager, enter the bridge, where they are greeted by a pleasantly smiling Janeway and a silent autodestruct countdown.
"Hello. I'm Captain Kathryn Janeway. Welcome to the bridge." BAH-WHAM
In Star Trek Into Darkness, Spock allows the torpedoes that contained Khan's crew to be transported to his ship. But not before he'd armed them.
One of these happens in The Fifth Element right near the end. After failing to escape, The Dragon races to stop the bomb that he had set to destroy the space cruise ship he is on. He succeeds with five seconds left on the clock... then turns to see ANOTHER bomb that his mutinous henchmen have set off, counting down from five...
Clouseau: Special delivery — a bermb. Did you order one? A BERMB?!
Die Hard, when McClane ties plastic explosives and a computer monitor to a swivel chair, with electrical cord, and drops the chair down an elevator shaft onto two mooks who were shelling an armored police car.
Something very similar happened with a mook in the Tim Burton Batman movie.
Samir Horn in Traitor is an American operative deep undercover in a radical Islamic terrorist organization. Their plan is to blow up fifty passenger buses across the United States simultaneously, and Horn is tasked with instructing the terrorists on which buses to board. He puts them all on the same bus.
In Law Abiding Citizen, the villain/protagonist/whateverheis has a napalm bomb placed in City Hall, intending to kill the major and the city's emergency service officers. However, the attorney he's been up against the entire film shows up and lectures him, telling him that if he detonates, he'll have to live with his decision for the rest of his life. He decides to detonate, not realizing that the attorney has placed the bomb underneath his prison cot.
Van Helsing: When the carriage Van Helsing is driving plummets into a ravine, Dracula's Bride Vernona breaks the door off the carriage, thinking Frankenstein's monster is inside... instead she finds a nitroglycerin bomb rigged to fire a salvo of stakes when it goes off...
In Resident Evil: Afterlife, Wesker flees from the Umbrella ship in a jet, then smugly activates the ship's self-destruct countdown - only to realize that Alice had already moved the device onto the very plane he's flying.
In Magnum ForceDirty Harry disarms the bomb that the villain planted in his mailbox and takes it with him. When he confronts the villain, he reactivates it and tosses it into the villain's car, who drives off, unaware.
He also does it in the first book, luring Root to Holly's transponder.
The Chessmaster in the last Empire from the Ashes book sets up the Emperor the bomb by disguising it in an important statue. By the time this is discovered, it is inside the most heavily defended section of the palace, has an anti-tamper device set to go off if Imperial technology gets close, and packs enough power in its bite-sized package to destroy a sun. Oh Crap.
In the the Halo novel Ghosts of Onyx, the humans on the planet Reach allow the invading Covenant to come into possession of a NOVA bomb, which is a basically a Mega Nuke capable of destroying an entire planet. The plan is for the Covenant to take it back to their capital for study and detonate it in the process. They instead take it to one of their colony worlds that nonetheless has a large fleet orbiting it,and inadvertantly set it off, annihalating the fleet and a great deal of the planet. However, the fleet that blew up was, while not exactly friendly to humanity, part of an Enemy Civil War against the main Covenant.
Happens in Storm Thief when Finch reverse pickpockets the explosive armband Bane attached to him while he the detonator for the armband. The future victim of the explosion notices that the detonator was stolen from him but is still cocky since the bomb should still be attached to it's intended target. He gets just enough time to realize the bomb is in his pocket.
Philip K. Dick's short story Impostor deals with a war between Earth and aliens from Alpha Centauri, and a man that is accused of being a robot, planted by the enemy and which carries a bomb inside, set to explode when a trigger is activated. The man escapes and tries to find the robot, to attempt to prove he is actually human. He isn't. And the bomb inside him explodes right after discovering the truth, laying waste to good part of the Earth.
Live Action TV
The ending of the three part "Hot to Katrazi" arc on Farscape had John dropping a mini-nuke into the Scarran's gardens.
A Xanatos Gambit variant in the stories "Remembrance of the Daleks" and "Silver Nemesis". The Doctor sees to it that his enemies gain control of a Gallifreyan superweapon, which ends up 'sploding the bad guys in space. Either way they can't use it and the Doctor says the device returns home, but blowing them up was a nice bonus.
Both the season one opener and closer of Leverage featured a bomb going off like this. The first was deployed by the villain, the second by the protagonists(though it wasn't meant to kill, only to destroy the evidence in their office)
Favorite tactic early on in Battlestar Galactica, since it ensured that the nuke took out a Basestar.
They did it to a Borg...rounded rectangular prism? in Star Trek: Voyager with a photon torpedo set to "overload" beamed onto it after Voyager had disabled its shields.
In the Made-for-TV MovieLegend Of The Rangers, the Rangers did this to the same villains on two separate occasions. The enemy did use precautions the second time, but the protagonists anticipated and nullified them.
In the episode "The Fall of Night", a group of Centauri try to set up Sheridan the bomb. Sheridan avoids the blast itself by jumping out of the shuttle just in time, but this only substitutes one deadly danger for another—namely, a potentially fatal collision with the station's outer wall. It takes an almost literal Deus ex Machina (albeit one that had been lightly foreshadowed) to save him.
Sheridan...actually REALLY loves this, and related, tropes. [[Thirdspace, his destruction of the Black Star, and his destruction of Za-ha-dum ALL involved very, very big bombs.]]
One opening quote in Andromeda gives us Argosy Special Operations requisition form, CY 9512:
"Requested: One Mark V ECM unit, 1000 km of Fullerene cable, one low-yield nuclear warhead. Purpose: Surprise party for a foreign dignitary."
In Mighty Morphin' Power Rangers: At the end of the third season, Lord Zedd sends Goldar and Rito into the tunnels under the Command Center to plant a bomb and blow the place up. It succeeds, quite chillingly, though Zordon had prepared for the possibility. And in the finale to Power Rangers Zeo, Rita and Zedd blow up the Royal House of Gadgetry with a package bomb. They get rebuilt by the beginning of Power Rangers in Space.
In the alternate reality of the Stargate SG-1 episode "There But For the Grace of God", the Jaffa invading the alternate SGC arrive at the gate room and control room just as the base self-destruct reaches zero. They can be seen milling about going Oh Crap as the P.A. system counts down, "Five, four, three, two, one..."
Honorable mention to the fireworks O'Neill used to booby-trap the MacGuffin in one of the training scenarios in "Proving Grounds". His trainees abort the "mission" rather than try to disarm them.
According to "Summit", the System Lord Ba'al apparently had a reputation for doing this to his enemies. In the words of Daniel Jackson, gifts from Ba'al "have a habit of exploding."
JAG: In "War Cries", an old lady leaves a basket in front of the Embassy's front gate. A Marine sentry sees this and immediately sounds the alarm just before the bomb explodes.
In Breaking Bad, Walter White finally kills Gus Fring this way at the conclusion of season 4.
In the old Dragon Ball Z Budokai game, Mr. Satan (AKA Hercule) uses an exploding portable console (looks like an oversized GBA) to trick his enemies in his Super Attacks. Everyone falls for it, even Cell...
In every last Bomberman game, you set the bomb up.
This is actually a cheat code in Starcraft that makes you instantly lose.
In the middle of the Zerg campaign, Kerrigan boards a science vessel to get the data she requires to break her psychic Restraining Bolt. A Terran demolition team boards the ship as well to destroy it and get ambushed. Seeing no way out, they detonate the nuke they brought with them to vaporize all the Zerg on the station... but Kerrigan's no longer onboard.
The Terran campaign of Brood War has Duran setting up the bomb to the UED Non-Entity General by luring him into the Psi Distruptor and setting the reactor on overload.
In World of Warcraft, the very first quest a new goblin player gets is to deliver a "present" from your executive assistant to a mining foreman who hasn't met quotas. You can guess what the present is.
Warhammer 40,000: Dawn of War: Dark Crusade has the player do this to the Necron stronghold. Especially with the Necron Pariah's reaction.
In the attact mode cinematic to Tekken 5, someone delivers a bomb to Heihachi Mishima via Jack robot.
In Mass Effect 3, after going to Sur'Kesh to get the fertile krogan female and coming under attack by Cerberus operatives, you go to the elevator to try to get topside, only to find a bomb in the elevator. Garrus says it best.
In Fallout 3, an optional sidequest (absent from the Japanese version) has you set up and detonate the nuclear bomb in the middle of Megaton. Doing this will put your Karma Meterinto the red, however.
Futurama: Bender's Big Score: "You've been scammed, sweetheart!"
Happens in the Beast Wars episode "Equal Measures." An energon vein that runs underneath both bases means that one can travel from one to another instantaneously but an explosion on one end will mean explosion on the other. Cheetor, in the Predacon base, sends this information to the Maximals via a data disk through this instantaneous connection... only for the bomb he was warning them not to use to suddenly appear in the base.
In the Transformers Animated episode "Decepticon Air", Optimus loads a pile of explosive energon cubes onto the lift and then cuts the lift cable, dropping it right down to the Decepticons waiting for him at the bottom.