You could make it a short take-home assignment where the code doesn't get used by the interviewing company and the assignment is short enough that the interviewee doesn't feel like they need to get paid for it. It would basically be the same as doing it in-person but removes the added stress of the over-the-shoulder scrutiny, leading to a more realistic scenario where a developer has resources such as Google and Stack Overflow at their disposal.
In my engineering days, a company I interviewed for had me prototype some stuff in SolidWorks but gave me the courtesy of working alone. I just had to tell them when I was done. Even this was much more preferable to an in-person on-the-spot tech interview. I got an offer for that job, but if I had to perform the same task with someone watching, I don't think it would have gone as well.