The problem would be the payment. That turns it into a paid gig and leaves a paper trail. A solution might be to allow the candidate to forgo payment in lieu of the interviewer making a donation (in the interviewer's name) to a charity of the candidate's choosing, so the candidate never sees any compensation.
IANAL, but actually the issue would be if the company were getting value out the developed solution.
In this case, the hiring company just seems to want to say "This isn't an actual problem we have, but we use it as a problem set, and you should be paid for your time" because this goes above and beyond an in-person interview.
Your (existing) employer (in California) wouldn't begrudge you for taking part in a user-research survey that resulted in a $100 Amazon gift card. This could be done the same way, the difference is that you're writing code (which is what you do for a living).