Do you have a spare drive around?
Can be USB SSD or a platter-based hard drive.
If so...
You could try booting to a special version of internet recovery:
Command-SHIFT-OPTION-R
This will install the ORIGINAL VERSION of the OS that shipped with the 2015 iMac (I think that's El Capitan).
You would want to try installing this on the EXTERNAL drive.
WHY:
Now you have an "alternate boot drive" with an OLDER version of the OS.
You can try booting to the old version, to see if that "wakes up" the thunderbolt ports and brings them back alive.
Aside:
I had the firewire port "fail" on my 2010 MacBook Pro within a year of buying it.
Apple swapped out the motherboard for new.
BUT... in another year, it seemed to fail again.
Out-of-warranty, I "let it be". Some time passed by...
BUT... I tried booting it from an external drive (used for another Mac), and -- like magic -- the firewire port "came alive" again.
After that, they remained alive even when I booted from the internal drive.