Changing the wallpaper on macOS is really easy from CLI using Open Scripting Architecture (OSA) and its tool osascript:

$ osascript -e 'tell application "System Events" to set picture of every desktop to ("~/Pictures/wallpapers/cool_wallpaper.jpg" as POSIX file as alias)'

Same thing using Javascript for Automation (JXA) . Save the code below to a file named change_wallpaper.js for example.

var system_events = Application('System Events');
for (desktop_item in system_events.desktops) {
	system_events.desktops[desktop_item].picture = '~/Pictures/wallpapers/cool_wallpaper.jpg';
}

Run it like this:

$ osascript -l JavaScript change_wallpaper.js