Personally I think it goes better in this scenario when the manager/tech lead is not the one at the keyboard. That way the person who's learning can make a lot of the decisions while bouncing ideas off the other person. If it just becomes watch my manager do some work it's very hard to focus and learn.
But the whole original problem was that the manager really wish to do that task to scratch the itch. You can't simultaneously do the task the way you want it and simultaneously have someone else having do that. You will end up either annoyed that he does it differently or he will end up having to guess until he reaches solution you had in mind all along. It is profoundly demotivating.
Such task is just about worst possible choice for teaching task. Imo, if you want to do that task and have time for it, do it and don't apologize for that. As long as you don't cherry pick all cool tasks it should be fine.
And you if you think you need teach them something, pick up task best suited for whatever you want to teach. Not one you wish to do yourself, but the one that is best for learning.
Don't have personal hidden agendas around things like teaching and pair programming. Pair if you think pairing is helpful, not when you actually want to do it personally, but feel ashamed because your title is manager.
"Do the task the way you want it." That's a far more mechanistic view of "interesting work" and "features I would like to do myself" than the parent seemed to express.
> giving to other engineers features that I would like to do myself" [...] I want to give my team members the interesting work and not hog all the cool stuff myself ...
It even implies that they are fully capable and that he trusts them to do those tasks. It also implies that he indeed would like do that task, because he finds doing that task "cool".
Both are marks of good leader and so is being self-aware. None of them implies him team members need to be taught or that teaching instead of doing task them would satisfy his wish to do the cool thing.