That should work, but if you use the easy UU method to accomplish this, then you get that cosmetic issue where if the civ has a UB and a UU instead of 2 UU's you'll see the dummy unit instead of the UB on the setup, dawn of man, and civilopedia screens.
There are somewhat unsatisfying workarounds to the UU issue, but the best solution would be, as whoward69 says, using the CS and Barb technique of setting the UnitClassOverrides to blank rather than the dummy unit, preventing training/purchasing of the unit class, then use a dummy tech that you grant only to the specific civ with Lua that allows them to purchase the dummy unit that's set up like a Landsknecht as purchase-only.