I suppose you would have to design the game to have at least two modes for this. You could call them "exploration mode" and "battle mode". Maybe a third "cut scene" mode as well.
In "exploration mode" the player moves the character(s) in the play field. When the player approaches an enemy the "battle mode" is activated. Manual player controls are then disabled.
I suppose you need to create a system that randomly sets the positions of enemies and players when "battle mode" is activated. You can create code that finds positions for all the enemy and player characters while checking that these positions are not too close to each other or within or too close to impassable terrain. Then you can use the "go to" behavior to move the sprites to their correct position.
Then you need to create a turn based battle system. This in theory should not be too hard either. You have to create a "speed" stat for player and enemy characters, and based on that a timer then calculates the action turn order.
The next part is probably the hard one. You need to create a bit more complex systems for all the "battle mode" menus, different attacks/magics/special abilities/item use etc. Specific actions are performed based on what the player chooses from the menus, after the battle timer has calculated that it is their turn.
As for the enemies, you probably want to use the advanced random plugin to make them use randomly different attacks. That would probably do for simple basic enemies, but you could also code more advanced attack patterns to different enemies to improve and diversify their behavior.
I don't have a template, but I don't see how you couldn't do it. It's just a lot of individual small parts that need to be put together one by one.