What would make ninja valuable in defending humanity from an alien invasion?
Imagine a scenario like that of XCOM (old or new), Xenonauts, Phoenix Point, or other various Alien Invasion stories: the world has come under assault from a massive alien force. They are much more technologically advanced, though fewer in numbers than humanity. They scout and assault in powerful UFO aerospacecraft, and occasionally fight on the ground with infantry. Their soldiers wield futuristic gun-like weapons that are much more powerful than contemporary ballistic weapons, yet no less accurate.
Their ranks are made up of a variety of species with extreme specializations, such as frail psychics, bulky ogre-like shocktroopers, and beastly hunter monsters. They have vastly varying physiology, and have all evolved on different planets wholly separate of each other. Some of them have been genetically modified to possess abilities incredible abilities of strength, agility, regeneration, and other phenomenal powers.
Humanity has a military organization prepared for just such a possibility. This group begins shooting down UFOs, as well as assaulting the grounded aliens with infantry.
...and for some reason, they use a significant amount of ninja. ...and it works.
How? Why? ...What?
This question is most inspired by Long War 2, a mod for the game XCOM 2 that, among other things, saw your soldiers specializing in a base class known as Shinobi. While the majority of the rest of your XCOM soldiers relied on guns and explosives - as a modern army reasonably would - the Shinobi combat the alien menace with swords. And it goes rather well; the Shinobi are a valuable assassin-style class with high burst damage and mobility.
This, of course, only works so well in Long War 2 because it's a game. The mechanics allow the ninja to move around on their turn uncontested, letting them close distances to melee range with gun-wielding foes much more easily than one would expect in reality. Sprinting about and trying to slash enemies to death with a machete will probably get you shot on a modern or futuristic battlefield.
How do we explain this effectiveness in a believable way? What context would make this reliance on stealthy melee fighters in combating the alien menace make more sense? What special alien-fighting purpose do they serve that other soldiers are less adapted for? Do the aliens have a crippling weakness that can be exploited best by sword-fighters? What techniques or equipment would allow them to be useful on such a battlefield?