Can a torpedo be destroyed by machine-gun fire?

That depends on the type of torpedo. Steam torpedoes leave a visible trail. Electric torpedoes are much harder to see.

Modern torpedoes, such as the MK-48 (which is neither steam-powered or electric), are also difficult to see.

I can think of one instance in which a Torpedo was destroyed with gunfire.
The Liberty Ship Robert J Walker destroyed a torpedo launched by U-862 off Tasmania in December 1944 with 20mm gunfire.
Here is a link.
https://uboat.net/allies/merchants/ship/3400.html
Mythbusters got it wrong.

Yes having read a few accounts of American Destroyers at war it seemed like it a torpedo was sighted and they couldn’t out manuever it (for instance of their speed was reduced) they had a specific order to fire all their guns in front of the torpedo in an attempt to detonate it. Everything from the main 5 inch battery to the 20mm AA guns.

There was also the famous case of a Japanese fighter deliberately crashing the aircraft in front of a torpedo to prevent it from hitting it’s aircraft carrier which worked.

To further add to this unsinkable thread: floating mines could be detonated by even light weapons:

“Minesweepers trawled Britain’s waters (in WWII). They cut the cables holding moored mines to the seabed. When they floated to the surface, deckhands destroyed them with rifles.”

AIUI a round might still be capable of penetrating flesh after passing through, say, a foot of water. Beyond that you’d need cavitating bullets.

Interestingly also some shots would reflect off the water’s surface, like a stone being skipped. It would be cool to see one of those shots land (though of course the shot is still going faster than the human eye, so you’d need to take some artistic liberies).

The scene is here, with the shots through the water starting about 2:15. There’s a lot of questionable stuff going on in that scene - the front of the landing craft that soldiers are bailing out of is in knee to waist deep water (you can see other soldiers wading ashore right in front of it), yet when they go over the side, the water is very deep - 10 ft or more. You can see soldiers upright trying to remove their gear, with at least 3 ft of water over their heads. And yes, assuming the soldiers are 3 ft deep and the bullets are coming in at a 45 degree angle, they’re penetrating 5+ ft of water before hitting & killing the soldiers.

When a Torpedo Got Stuck in the Side of a Submarine - just happened to be in my Youtube feed.

Welcome to the boards, @brians234! Hope you’ll stick around!