Mind control is almost always left up to the GM
Technically, you simply cannot tell a creature to "use a legendary action" as those don't exist in-character; you'd instead have to describe what you want the creature to do and then the GM would determine how that plays out. This is the case for mind control in general, and this is no exception.
When you tell a monster to do something, perhaps the easiest way for them to do that would be by using their legendary, lair, or other sorts of actions. Whether the creature actually uses these is the GM's decision because the game's rules are silent here. There's no exacting description or definition of the extent of what you can force a creature to do through generic commands.
That said, let's look at dominate monster more closely:
While the creature is charmed, you have a telepathic link with it as long as the two of you are on the same plane of existence. You can use this telepathic link to issue commands to the creature while you are conscious (no action required), which it does its best to obey. You can specify a simple and general course of action, such as "Attack that creature," "Run over there," or "Fetch that object." If the creature completes the order and doesn't receive further direction from you, it defends and preserves itself to the best of its ability.
You can use your action to take total and precise control of the target. Until the end of your next turn, the creature takes only the actions you choose, and doesn't do anything that you don't allow it to do. During this time, you can also cause the creature to use a reaction, but this requires you to use your own reaction as well.
You cannot specifically tell a monster to use a particular legendary, lair, or other sort of action because that command would be far more specific than a general course of action. In order to do this, you would have to take total and precise control of the target, which the spell explicitly allows you to do. Then you would have to describe what you want the creature to do and the GM would narrate the results.
However, again, if the generic course of action is best carried out through specific actions it will fall to the GM to determine what actually happens at the table. This is the case for almost every single command you could give - the GM determines what happens.
Similarly, the Necromancy Wizard's Command Undead feature says that the creature "obeys your commands". What this means, what you can command it to do, the amount of knowledge you have about its available actions, and the precision allowed in your commands is entirely going to be up to the GM.