Change background image through terminal on macOS Sierra
How about if you setup your preferences to use a photo from a folder. Then your script can just drop the picture into that folder and the system will pick it up.

If you set your preferences to switch every 5 seconds, then you can change out that image whenever you script wants, and it'll be picked up within 5 seconds.

Just did a quick test moving images in and out and it works.