Not WW2, WW1.
I remember reading that there was one officer who committed ritual Hara Kiri in the First World War but I can't find it again, plus it wasn't referenced or evidentiary and was hoping to find a better source.
He was following the honour code from Samurai times when he disgraced himself by failing in the line of duty. Japanese forces had around 100 warships patrolling and providing escort to allied troopships for nearly the whole war. For a time they had a squadron based in the Mediterranean on anti-sub escort duty. This is where the likeliest candidate for this story comes from.
In a troop convoy, the destroyer IJN Matsu (1915) was one of the armed escorts for the SS Transylvania. 4th May 1917 in the Gulf of Genoa, U-63 torpedoed and disabled the Transylvania, then the Matsu came alongside to take on souls. Later, U-63 launched again, this time at the Matsu. The captain saved the Matsu by going full astern thus avoiding the torpedo, which unfortunately hit the Transylvania, sinking it with the loss of 412 lives. The stories I've found on this are not clear on many details but this is the only story I know of where a Japanese officer failed during the war. In fact its one of the very few stories out of WW1 that involve the Japanese armed forces at all.
I'm saying this story is the most likely source of the origin of the story about the Hara Kiri, but does anyone know more or have evidence? I don't know enough Japanese language to research it properly that way.
Source: reddit post