The submarine USS Tang reportedly did this on October 25, 1944.
Rammed an enemy aircraft carrier
Shelled Tokyo
Shot down five enemy warplanes
Sank itself
Sank itself. On its fifth war patrol, a torpedo fired at an enemy ship malfunctioned. The torpedo circled back on the Tang and struck her in the stern. Nine men, including the sub’s commander, survived the sinking.