The spell itself is easy enough: create an attack with the "Confuse" element. If you want it to deal damage, too, then you can do that.
The implementation is a bit more involved. Each confusable enemy will need two enemy entries: one for its normal state, and another for its confused state. You'll also need to create self-targeting attacks to transmogrify the enemy both ways. (Note to James/TMC: it'd be great if enemies had their own transmogrify-on-hit menus.) Set up the normal enemy to transform into confused as a counter to "Confuse" element. You can choose which attacks trigger the reverse transformation. The Final Fantasy games only remove Confuse on physical damage or Esuna/Remedy, but this is your game, so do it how you want.
The same technique can be used to create other status effects, too, like Berserk and Sleep. Now, all we need is AI-controlled heroes and hero transmogrification