The fact that this happens when the phone is in my pocket and not when it simply lays on a table might suggest strongly that the power button is just pressed but I find this explanation unsatisfactory because (a) it did not happen before (b) there are 4 ways to slip a phone in a pocket and it happens whatever the way.
Since /e/ v 1.0 arrived there are reports of Samsungs getting warmer than usual and also of contamination of cache of various apps.
So your linked article might be useful to you. I read that Samsung have hidden the temperature sensors except in the battery. I found that the Battery Bot (Pro) gives me the battery temperature which at least gives an sort_of_useful indication of internal temperature.
If you boot into Recovery with Volume Up + Home / Bixby + Power buttons do you find TWRP?
It may have been replaced by /e/ Recovery on your phone, idk.
From TWRP you can do the system wide Clear cache mentioned in your link by
Tap Wipe
Tap Advanced Wipe
Tick cache
Swipe to Wipe
Reboot System
I do not have an /e/ Recovery to check the method here (perhaps you will find the option if you explore a bit.)
You might also check that the power button always retracts fully and squarely, this might potentially cause over sensitivity. I had this on volume buttons and fixed it with a microscopic amount of silicon grease used to clean the edges of the buttons and the slots. I took great care to get no grease into the case!
With a long press Power button > Long press Power > Reboot to safe mode > OK
you can temporarily disable all third party apps, in case some app which you added is causing the over sensitivity.
On the mechanical side of the problem: since I posted the question, it has happened twice that the phone rebooted randomly while it was not in my pocket. Besides, I checked the spring of the power button, it seems in perfect shape.
My phone does not have TWRP but /e/ Recovery instead. In spite of my searches and trials, I have not been able to find how to wipe the cache in this case. Some forums say modern phones don’t have a cache partition anymore.
I looked at the forum discussion here. It says "On many modern devices, there simply is no cache partition anymore, so there’s nothing to wipe. " I am too ignorant to judge such a claim.
I have not explored every option of /e/ Recovery because some seem quite risky. For instance, I have found here that the “reboot to bootloader” option could be used to wipe the cache data, but when I tried on my phone, it displayed a screen of some heavy download, so I just quit out of fear.
There is a TWRP Recovery for star2lte, but these suggestions were only meant to be easy ones, I am not very confident that this will be a solution. Perhaps someone else can offer an idea.
It would be very much a last resort to reinstall /e/. If you felt it had come to that you might just try installing TWRP as your recovery; wipe cache; test your device with the current install + your new TWRP. If this showed no benefit, then go on to a reinstall of /e/.
Just to give an update on my situation, in case someone has the same trouble some day.
I decided to reinstall /e/ completely… and it did not solve the problem. The phone was still rebooting randomly.
To see if it was specific to /e/OS, I then tried to install the original commercial samsung OS (freely accessible on their website), and the problem persisted.
So I concluded it was a hardware problem, and since the warranty was still working, I sent the phone back and I was reimbursed.