When making a melee attack against a creature that reduces it to 0 HP the attacker can declare the attack incapacitating rather than lethal: "the attacker can make this choice the instant the damage is dealt. The creature falls unconscious and is stable." (PHB p.198, "Knocking a Creature Out")
Does this work on constructs and undead? Let's look at the specific cases of Animated Armor (MM p.19) and Zombies (MM pp.315-316):
- neither require sleep by dint of their Constructed or Undead Nature;
- neither is immune to the unconscious condition;
- in case it matters, neither undead nor most constructs are susceptible to Sleep. (Undead are called out by name, most constructs inherit Sleep immunity from their immunity to being charmed. Modrons, however, are not immune to being charmed and thus not immune to being put to Sleep.)
For both creatures sleeping just isn't a thing they do. But it would appear that you can knock them out with a well-placed tap on the back of the head/helm? (It gets even stranger when you start thinking about extending this thinking to a Flying Sword (MM p.20) or a Ghost (MM p.147).)