**
IMPORTANT:
OUTDATED ANSWER, LOOK AT THE OTHER NEWER SOLUTIONS
**
You can do it for macOS, too. Ok, not through code, but with some simple steps:
- Find the .icns file you want to use, open it and copy it via Edit menu
- Find the electron.app, usually in node_modules/electron/dist
- Open the information window
- Select the icon on the top left corner (gray border around it)
- Paste the icon via cmd+v
- Enjoy your icon during development :-)
Actually it is a general thing not specific to electron. You can change the icon of many macOS apps like this.