Yes, with a ranged spell that does a melee attack
Arguably, you can knock them out at range with a Spiritual Weapon attack or the Clenched Fist from Bigby's Hand, or when attacking with spells like Animate Objects or Mordenkainen's Sword.
While your DM may not agree, we'll walk through the logic on this. Using as an example spiritual weapon (which reaches out to 60 feet away) ...
What does Spiritual Weapon do?
It makes a melee spell attack on a creature. (Ch 11, Level 2, Range 60')
You create a floating, spectral weapon within range that lasts for the duration or until you cast this spell again. When you cast the spell, you can make a melee spell attack against a creature within 5 feet of the weapon. On a hit, the target takes force damage...
Is this a melee attack? Yes, a melee spell attack is still a melee attack, even if it has a longer reach than 5' away.
Melee Attacks (Ch 9)
... a melee attack allows you to attack a foe within your reach. A melee attack typically uses a handheld weapon such as a sword, a warhammer, or an axe. A typical monster makes a melee attack when it strikes with its claws, horns, teeth, tentacles, or other body part. A few spells also involve making a melee attack. Most creatures have a 5-foot reach and can thus attack targets within 5 feet of them when making a melee attack. Certain creatures (typically those larger than Medium) have melee attacks with a greater reach than 5 feet, as noted in their descriptions.
Spiritual weapon's 'reach' is up to 60'.
A melee spell attack is a kind of melee attack.
Shocking Grasp (Make a melee spell attack against the target) and Inflict Wounds (Make a melee spell attack against a creature) are other exmples of spell attacks that are also melee attacks.
Knocking a Creature Out (Ch 9)
When an attacker reduces a creature to 0 hit points with a melee
attack, the attacker can knock the creature out.
Here's the logic train: a melee spell attack is a melee attack, spiritual weapon is a spell that makes a melee attack with a range/reach of up to 60', it takes a melee attack to knock a creature out (rather than kill it) when an attack that drops them to 0 HP, thus you can use spiritual weapon to knock out a foe at range.
Reach out, reach out and touch someone!
I am confident that this logic also works for:
Bigby's Hand (Clenched Fist). (Ch 11, level 5 spell, range 120')
The hand strikes one creature or object within 5 feet of it. Make a melee spell attack for the hand using your game statistics. On a hit, the target takes 4d8 force damage.
Animate Objects(Ch 11, level 5 spell, rang 120')
If you command an object to attack, it can make a single melee attack
against a creature within 5 feet of it.
From Mordenkainen's Sword (Ch 11, 7th level spell, range 60')
When the sword appears, you make a melee spell attack against a target
of your choice within 5 feet of the sword. On a hit, the target takes
3d10 force damage.
At table experience
I've not yet had a DM disagree with the above logic. When I DM this is an option if the PC or NPC is wielding their spiritual weapon. (This once allowed me to have an NPC knock out a fleeing PC rather than kill them ... after which the rest of the party had to rescue them later ... )
As for the higher level spells, none of us thought to knock the enemies out in the fights where I saw those used by wizards. But I think we could have.
Credit and thanks to @NautArch for getting me to check spells other than spiritual weapon