I am not in game development but I think that HaXe might help you.
Note that HaXe can create Electron apps.
Just a different permutation of options.
So can Electron itself compile to a DLL instead of and EXE?
In other words: no