Firstly locate the image you want to use and the file, whose icon will be changed.
To do so, open the image in Preview.
Click on the Pencil in the circle to enter the editing mode and select the grabbing tool.
Now, using the grabbing tool, select the entire image and click Cmd+C
.
After that, go to the file, select it and hit Cmd+I
to open the Information menu.
Select the icon on top of the window right near the name of the file and hit Cmd+V
.