Here is an AppleScript using Objective-C to select the image, and then select the folder target. It places the image on the folder. There are three ways to revert the folder icon:
- Run the script again with a different picture (ideally a .icns)
- Run the script again with a .svg image which is not supported, and will restore the original folder icon
- Get Info on the Folder, and double-click its image well in the Get Info panel, and press backspace.
Here is an image of the dog cow placed on a folder:

or an .icns with some transparency:

Launch the Script Editor from Dock : Launchpad : Other, and copy/paste the following ASOC source into it. Press its compile button, and then run it. You can save the script as text (applescript), script (.scpt/scptd), or application (.app).
use framework "AppKit"
use AppleScript version "2.4" -- Yosemite or later
use scripting additions
property NSImage : a reference to current application's NSImage
property NSWorkspace : a reference to current application's NSWorkspace
property imgType : {"public.image"}
-- Choose Image first
set theImg to POSIX path of (choose file of type imgType default location (path to desktop) without invisibles)
-- Chose folder next
set theFolder to POSIX path of (choose folder default location (path to desktop))
set imgFile to NSImage's alloc()'s initWithContentsOfFile:theImg
set status to ((NSWorkspace's sharedWorkspace)'s setIcon:imgFile forFile:theFolder options:0) as boolean
return
Translated from a Python/Objective-C script since Apple is vanquishing system installations of Python, Ruby, and Perl in a forthcoming release of macOS.