When teaching people to code, I'll dictate for a bit, and then start asking questions as I go, and move them gradually toward building things on their own. Really only a technique that works one-on-one but it's worked very well.
A vital part of that is to ask questions that don't just regurgitate dictation, but to encourage risk taking. The more comfortable a student is with the possibility of being wrong, the more natural experimentation becomes. Always connect it back to progress toward something they are passionate about, whether they are technically inclined from the outset or not. This is why I like to skip "Hello World" type coding and fast-track them to making a tool that they actually want to use in their lives.