You could try modifying the entity's minecraft:generic.attack_knockback
attribute using the /attribute
command like so:
attribute @s minecraft:generic.attack_knockback base set <value>
<value>
being a number ranging from 0.0 to 5.0
If you wish to use the item method, you could use the /replaceitem
command to give the entity an item with the knockback enchantment in its mainhand. Here's an example:
replaceitem entity <targetEntity> weapon.mainhand minecraft:stick{Enchantments: [{id: "minecraft:knockback", lvl: 1s}]}
<targetEntity>
being the entity you'll give the item to. This field accepts either UUID, or a target selector. (e.g @e[type = zombie]
)