Interestingly enough, it appears that it does happen sometimes even when not using the pen. I didn't notice it, I don't know whether the screen just didn't go black or the lid was closed, but it still shows up in Reliability Monitor with the same HeatCore.dll issue.
The reason why I noticed is that there is another effect of dwm.exe crashing: Microsoft Teams (and sometimes some other Electron-based apps ... maybe) go black (but only sometimes), so I have to restart it completely in order to use it.
Anyway, according to MS support, their technical department should get back to me in the next couple of days, MAYBE they come up with a fix. Hopefully.