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).)
Best Answer
For Constructs (such as Animated Armor), no.
Monster Manual pg.19 covers this.
As for golems, which are much more powerful construct, the answer is still no.
Monster Manual pg.167 covers this (emphasis mine):
As for undead, yep, nothing seems to prevent that.
So I looked up ghouls, ghosts, skeletons, and zombies to see if any of them had the 0 HP limit like armor does. The answer is no. Interestingly enough, the skeletons can even use their brain and think through rudimentary problems. It seems undead have a little more agency in 5e. So it looks like you could knock out an undead, which makes sense. I mean, vampire spawns are undead, and they sleep, which means they have an unconscious state. Even mummies sleep until you step into the plot device that wakes them up.
Exception
Helmed Horror - MM pg.183 (Intelligent construct). It has Constructed Nature, but does not become useless armor at 0 HP as it is not explicitly stated. You could of course rule that Constructed Nature makes it that way, however a Helmed Horror is specifically imbued with actual Intelligence.