Screeps comes to mind, if JavaScript is okay. Human Resource Machine is lower level but useful for teaching basic concepts.
Good though they are, I would not recommend any of the Zachtronics games since they are focused on being coding puzzles, not teaching.
It teaches programming OK, but it's not a very interesting/fun game. It's more like programming lessons with game elements tacked on. So you actually waste a lot of time doing boring "game" things like walking around a map looking for stuff. You collect stuff like weapons/armor but 99% of the items don't affect the game in any way.
I 100% completed the Twilio API levels and API academy. It wasn't fun so I didn't bother to try the JavaScript/Python modules. (Also it was a little too basic for my level. TwilioQuest may be more engaging for kids who don't know how to program, yet.)
---
This doesn't exist yet, but I'd like to create a VR experience that teaches programming. You can write "spells" that use the magic of loops and variables to generate objects in VR and automate them.
For example, a quest like building a forest of 10,000 trees could be done manually, but writing a VR "spell" would be the smarter, faster way. Later, this VR spell could be used/modified in the future for other tasks or just general VR content generation. It's not just a game, it's a platform for VR content generation.
For now there doesn't seem to be a massively popular game on the topic probably because most educational games feel forced.
This is the impression that Twilio Quest gave me after looking at let's plays on YouTube.
Anyway, your idea sounds interesting however to know if people would like this you need to prototype it somehow.
It's not exactly programming, but I think https://vim-adventures.com/ is the best example of a game that teaches a skill.
Just making a good game is difficult. Just making good teaching content is difficult. So trying to both simultaneously will be at least doubly as difficult.
---
As for my VR scripting idea, teaching programming isn't the main goal. When VR becomes the next social media, the content creators will either need to do a lot of manual work constructing experiences or learn how to program. It's really hard and messy to create an interactive VR experience without knowing how to program.
So my VR scripting tool/platform will solve a painful problem. A lot of creators won't be programmers, so I think teaching them how to program/use the tool via a game would be helpful.