If Lightning Strikes X Mob It Turns Into Y Mob

I am currently trying to make a datapack so when certain mobs get struck by lightning they turn into a different mob. For instance how a villager will turn into a witch, or a pig into a zombified piglin. I would like to do it with horses into zombie horses. What is the best way of achieving this?

Continue to help post