Yes this was frequent occurrence for both the Imperial Army and the Imperial Navy.
At Midway for instance it was not just Yamaguchi who chose to go down with the carriers: the Captain of the Hiryu Tomeo Kaku chose to go down with the ship with Yamaguchi. Of the 4 IJN carrier captains at Midway only one: Taijiro Aoki of the Akagi survived. And that was after he ordered his men to tie him to to the ship as it was about to be scuttled, only to be given a direct order by his superior to abandon ship with the rest of the crew. Nagumo himself evidently contemplated suicide after losing his carriers and was only talked out of it by a subordinate: though he would eventually kill himself during the battle of Saipan.
This was a serious issue with the Japanese military during WWII as a whole: a lack of appreciation for the value human capital. The lives of personnel, both enlisted men and officers, were viewed as disposable. Among the officer class a repeating pattern is for the imperial military to conceive of a plan, then for the plan to fall apart, and for the commander executing it to commit suicide as atonement. This obviously has the effect of preventing officers learning from their failures. And depletes the pool of experienced commanders for the rest of the war.