First of all, you can not assign an icon to a stream so save the file first. Then probably,
IconHandlers can do your job but it's not that easy.
You need to create a shell extension handler to do this and preferably you do this using language like C++.
Check this complete article in MSDN
https://msdn.microsoft.com/en-us/library/windows/desktop/cc144122(v=vs.85).aspx[
^]
Hope, it helps :)