The main thing that keeps the Gym Leader from being a high boss level is the fact that some of the Pokemon like Kartana become too fast and overwhelm the player. So why not increase everything but Speed? I was thinking about the aura mechanic that Ultra Beasts have where one of their stats increase when you challenge them, and I was thinking the Gym Leader could have something similar happen to all of their Pokemon.
They wouldn't actually get any stat stages, but a modifier would be applied to their Attack, Defense, Special Attack, and Special Defense. The modifier would be 1.5x for the Gym Leader. You could also do something like this for the Epic and Legendary Trainers as well, but with a smaller modifier of 1.2x for Epic and 1.3 for Legendary. They would have those stat modifiers instead of being set to Epic and Legendary. There would be some message at the start of the battle with those Trainers that in some way indicates that the stats are higher. For example, "<Epic Trainer>'s Pokemon look tougher than average...", "<Legendary Trainer>'s Pokemon look quite strong...", and "<Gym Leader>'s Pokemon look very powerful..."
This would allow the Gym Leader to become a challenge without being too powerful (it would be weaker than an Ultimate boss due to not having a 1.5x level factored into damage, it would take less hits due to not having higher HP, and it would not have a speed advantage). This also, if done for the Epic and Legendary Trainers as well, would fix the fact that the Legendary Trainer is usually harder to beat than the Gym Leader. The difficulty level would be rising as you make your way through the Gym.
Stat modifiers could be factored into the Boss system, so that instead of having Epic and Legendary trainers and the Gym Leader being Equal, we could have say an Ace Trainer boss replacing the Epic Trainer, an Elite Trainer boss replacing the Legendary Trainer, and the Gym Leader boss for the Gym Leader. Or, stat modifiers could be another field that we edit in the NPC Editor.