Yomiji's ability triggers whenever any legendary permanent is put into a graveyard from the battlefield, not just legendary creatures.

Artwork
Loading artwork…
Yomiji, Who Bars the Way
Betrayers of Kamigawa · #30 · EN
Nonfoil—Foil—
Card rules
Whenever a legendary permanent other than Yomiji is put into a graveyard from the battlefield, return that card to its owner's hand.
4/4
"As I died, I rejoiced. I would see my family again. But then I woke up back on the battlefield. Back in Kamigawa. Back in hell." —Kenzo the Hardhearted
Rare · Illustrated by Hideaki Takamura
Format legality
Commander Legal
Duel Legal
Legacy Legal
Modern Legal
Oathbreaker Legal
Penny Legal
PreDH Legal
Vintage Legal
Alchemy Not Legal
Brawl Not Legal
Competitive Brawl Not Legal
Future Not Legal
Gladiator Not Legal
Historic Not Legal
Old School Not Legal
Pauper Not Legal
Pauper Commander Not Legal
Pioneer Not Legal
Premodern Not Legal
Standard Not Legal
Standard Brawl Not Legal
Timeless Not Legal
Tlr Not Legal
Rulings
Published rulings from the downloaded Scryfall catalog. Source card record · Rules and interactions
Yomiji's ability triggers even if Yomiji is going to the graveyard at the same time as the other legendary permanent.