Instead of using a commandblock you should consider using a datapack instead. Of course this does depend on what exactly it is you're trying to do.
But anyway... (random) drops are set up using so called
loot tables. Which can be customized and created... using a datapack. However, applying such a loot table is indeed something you can do using a command block or a function. When working on chests and what not you're looking for the LootTable, but when messing around with entities then this is the DeathLootTable.
Changing these is easily done using the
/data command. Let's say we want to prevent a cow from dropping items:
- /summon minecraft:cow ~ ~ ~ {NoAI:true, Tags:["m00"]}
- /data merge entity @e[tag=m00,limit=1] {DeathLootTable:""}
Try to kill the cow, you'll notice that it no longer drops any raw meat and/or leather. In fact: it doesn't drop anything at all anymore, that's because we changed its loot table from default to nothing at all. So how about we make the cow "posessed" and let it drop the same loot as a witch?
If you check the Minecraft client archive you'll find: "data\minecraft\loot_tables\entities\witch.json" which is the loot table for... the witch (duh!). So why not apply that to the above cow? =>
- /data merge entity @e[tag=m00,limit=1] {DeathLootTable:"minecraft:entities/witch"}
Now try killing the cow again, and... what do you know... no more meat but other weird stuff ;)
Nothing too hard, right?