AI identification of friends and foes is the most likely and most realistic candidate
Really, the most realistic way to achieve that is to help soldiers identify targets before they manually shoot them with conventional weapons.
AI could be used to identify friends and foes. We've made enough progress with AI that it's not unconceivable to have a well-trained AI model that can interpret what the soldier sees and paint targets.
Displaying the information would be fairly trivial, and we have already plenty of examples of what that would look like if you've ever played a shooter in the last decade.
The next technological leap would be to link IFF to the trigger of the guns, forbiding it to shoot non-friendlies (excluding civilians), maybe even non-hostiles (including civilians). Then the next step would be systems that can point at a target autonomously, and either fire at will or fire on command.
Mistakes will still happen, and it's not some kind of smart bomb that kill all baddies in a city leaving everybody else alive. But on the bright side, it also doesn't shoot your own guys, which is something a smart bomb would have trouble achieving.
This supposes the enemy follows the laws and customs of war, which includes showing your true colours (i.e. wearing an identifiable uniform of your own faction, and bearing arms clearly). Not because not doing so would be a war crime (which it is, but that's only a problem if you lose), but because that's a good way to trick your own troops into shooting themselves.
That covers what the technology could be. We'll cover how it can be perverted, but before we get there I need to say two things.
It doesn't need to be a working weapon
"An engineer is working on an energy weapon" doesn't mean there is a fully working prototype yet, let alone a production version. It might work in a lab under ideal conditions, but hasn't been field-tested. As such, it may have flaws to be resolved that makes it good enough for paintball but not enough to be deployed. And certainly enough to envision its limitations and all the ways it can be perverted.
In fact, it doesn't need to be a weapon. Technology can be designed for non-combat purposes, only to be coopted by the military to shoot at people. Or seemingly innocent technology being funded by the military to make it easier to shoot at people.
There are precedents for that. The Silicon Valley first thrived on US government contracts, being both the biggest financer and biggest client of early electronics. Why? Well to make better targeting systems for missiles. GPS famously is US military technology. Encryption was once classified as a weapon. You'd be amazed the amount of technology in your pocket that owe its existence to the military-industrial complex.
So it's entirely possible for your "weapon" to be a new form of AI training, some fundamental research on a new physical phenomenon that happens to make grenades explode randomly, or some other seemingly innocent prototype.
It may or may not work as advertised, but it doesn't matter too much because...
Never underestimate the magic thinking of generals
It would be very easy for generals to consider the weapon works exactly as described this far: a perfect weapon that only kill the people you want dead and not anybody else. After spending billions of moneys into it, they'd be right to expect that it should work as advertised. And they might even convince themselves that it does, at least until they start using it and realise it doesn't really.
It would also be very easy for generals to consider that anybody that the weapons kill was an intended and justified target. The obvious example here is "strategic" bombing. You level whole cities, and it's not terror bombing because it's totally justified, you're only shooting at the military, or its support industries, or whomever works for those support industries, or whomever supports those who support them.
Whatever helps them sleep at night, or not look like monsters after the war is over.
For the engineer however, it should be obvious how the "weapon" can be used and abused.
No matter how it works, the engineer should be scared of it
The idea of a weapon that can be targeted against a specific group of people is frightening. Today you're shooting enemy soldiers, tomorrow you might be shooting at protesters, and the day after that at ethnic minorities. All horrific prospects for people with a conscience.
And those concerns are very justified with AI models. AI doesn't erase societal biases, quite on the contrary. It is near impossible to remove biases in training, and there are a lot of them in our data. It would be quite easy to imagine an AI trained to shoot at Middle Eastern soldiers and not your own majoritarily white troops, that ends up shooting anybody with dark skin regardless of the uniform or lack thereof.
It doesn't really matters how it works, or if it works. The simple fact that it might one day work should be enough for the engineer to want to scrap it, and enough for the powers-that-be to want it.