You can do this using /replaceitem
and a technique similar to the one described in Fabian Röling's answer to this related question:
/execute if entity @s[nbt={Inventory:[{Slot:0b,tag:{discard:1b}}]}] run replaceitem entity @s hotbar.0 air
…
/execute if entity @s[nbt={Inventory:[{Slot:8b,tag:{discard:1b}}]}] run replaceitem entity @s hotbar.8 air
/execute if entity @s[nbt={Inventory:[{Slot:9b,tag:{discard:1b}}]}] run replaceitem entity @s inventory.0 air
…
/execute if entity @s[nbt={Inventory:[{Slot:35b,tag:{discard:1b}}]}] run replaceitem entity @s inventory.26 air
/execute if entity @s[nbt={Inventory:[{Slot:-106b,tag:{discard:1b}}]}] run replaceitem entity @s weapon.offhand air
I haven't had the opportunity to test this yet, but it should work.