To be clear, I'm unclear on whether you're asking for balance analysis, but you've provided a list of items from which you'd like the proposed weapon evaluated, so I will try to respond specifically to those elements.
Are the mechanics as presented clear?
You've indicated that the weapon has the following properties:
- Heavy
- Two-Handed
- Reach 10'
- One target
- 1d8 piercing
Given that this is intended for use by a monster and not a player character, I would limit yourself to simply the 'to hit' bonus, the reach, the number of targets, and the damage amount.
As written, this conflates the weapon properties detailed and applicable to players with the information typically provided in a monster's stat block. Presumably, you're doing the latter, so just do that.
To that end, you've provided the relevant information for what occurs on an escape, so that should follow:
On a successful hit, a target of size S or M is Grappled (escape DC12). A target that escapes the grapple must immediately move directly away from the wielder of the fork until out of their reach before resuming normal movement.
I should point out that it's unclear whether the drow would get another AoO because the opponent is moving out of their reach. You may want to specifically state that the drow cannot get another AoO.
Any attack from a military fork (normal or as a reaction) made on opponents within 5 feet is at disadvantage.
If the fork is currently grappling an opponent, no attacks with it (regular or as reactions) may be made on any other target.
I think you can probably reword the element regarding no additional attacks while grappling, which I'll address at the end with a recommended re-write.
You should list as a separate Reaction within the monster's block the following information:
As a reaction, the wielder of the fork may make an attack on an opponent that enters their reach. If the attack hits, the opponent's speed drops to 0 for the rest of the turn. This stops any movement they may have been taking.
This should be clarified as whether the opponent's speed drops to 0 because of the attack or because the opponent becomes grappled. If the latter, state that they're grappled per the weapon's description and let the rest of the game's general rules handle the rest.
Is this appropriate for its intent? Do the mechanics as presented make sense for a weapon used to defend a static fortification but of much less use on the open battlefield?
I am interested in whether this is balanced for use among drow - do the mechanics as presented make this the best weapon among those they traditionally carry for its use here, but not something they would have elsewhere?
The issue I see with this is that within the mechanics of 5e, there is really no substantial drawback to carrying this weapon and another weapon. You might start with this weapon equipped, use it for an enemy's opening charge and then drop it to switch to a great sword.
The argument might be made that it's too costly to arm every soldier this way, but ultimately it's an extremely good weapon that has a lot of uses beyond just the described situation of defending the castle walls. Having this weapon means that, barring ranged attacks, my melee combatants always get to attack first; furthermore, they then get to drop their forks and proceed to attack again. That's 2 rounds of attacks dealt to my opponent before they can respond.
Were I the drow, I would be using this all the time. Almost any enemy they encounter in the Underdark would be made more manageable by their soldiers equipping these forks and another sidearm. Even if they cannot stop an opponent because they're large, they get the benefit of having the ability to attack an opponent before that opponent can attack them.
I am somewhat interested in balance and possible interactions in the hands of PCs, but this is not intended for PC use. If a good case is made for why it produces unbalancing interactions with other PC abilities, suggestions for changing it would be appreciated.
At current, I'm concerned that the drow NPCs would be hard-pressed to deny using this everywhere. For the reasons described above, the PCs would most definitely get a lot of benefit from having access to this type of weapon.
As stated in the comments, the features of this weapon are akin to having both the Sentinel feat (to drop an opponent's movement to 0 with an AoO) and the Polearm Master feat (to attack an opponent as an AoO that enters your reach).
Recommendations
As I stated above, I would recommend a re-write to try and bring this in line with what's used in the MM first and foremost. As part of that re-write, I would strive to avoid language that intermingles language from the PHB as there's a lot of reasons to keep this out of the hands of players. I recommend the following:
Drow Wall Guard
Actions
Sticky Long Spear. Melee Weapon Attack: +2 to hit, reach 10 ft., one target. Hit: 6 (1d8+2) bludgeoning damage, and the target is grappled (escape DC12). Until this grapple ends, the drow wall guard can't use its sticky long spear on another target. The drow wall guard has disadvantage on sticky long spear attacks against a target within 5 feet of them.
A target that escapes the grapple must move directly away from the drow wall guard until out of their reach before resuming normal movement, this movement does not provoke an Attack of Opportunity for moving out of an opponent's reach.
Reactions
Sticky Long Spear. The drow wall guard makes an attack with its sticky long spear when an opponent enters their reach.
This proposed revision used elements from the octopus, bandit captain, lance description, and pulled them together to create a custom weapon that's usable only by NPCs. You will note that I've removed any specific mentions of dropping an opponent's speed to 0, that language is inherent with the opponent becoming grappled.
You may wish to supplement with some language about how the long spears are regularly blessed by a priestess of Lolth to continue exuding webbing that's used to facilitate the grappling mechanic, but the webbing also glues the drow wall guard's hands to the spear (so they can't be easily disarmed). In doing so, you help restrict the usage of such a weapon beyond every rank and file soldier, and make it unusable by soldiers who are far away from the main cities, and finally make it so that these soldiers can't easily just switch to a better weapon when the situation devolves against them.