Good question

One hurdle is that TDM on TB iMacs requires TB video input, i.e. an eGPU that provides TB video output like the Blackmagic RX580 or Sonnet Breakaway Puck RX5500/RX5700.
A Thunderbolt iMac can do Thunderbolt TDM because it has a Thunderbolt host controller that has a DisplayPort Out Adapter (use
ioreg to view the Adapters of a Thunderbolt controller). Most Thunderbolt host controllers don't have a DisplayPort Out Adapter. They usually only have two DisplayPort In Adapters.
Thunderbolt TDM works by having the Thunderbolt host controller of another Mac setup a Thunderbolt DisplayPort path between that Thunderbolt controller's DisplayPort Out Adapter and the DisplayPort In Adapter of the iMac. The path setup is triggered by typing Command-F2 on the iMac which initiates some kind of communication between the Thunderbolt NHI of the iMac and the other Mac. Command-F2 also switches a DisplayPort MUX so that the iMac display is connected to the DisplayPort Out Adapter of the iMac's Thunderbolt host controller instead of the DisplayPort output of the iMac's GPU. The Thunderbolt DisplayPort path is special because it is between two Thunderbolt host controllers - which means it's a cross domain path (each host has it's own domain).
I suppose it could be possible to setup a normal (not cross-domain) Thunderbolt DisplayPort path from the BlackMagic or Sonnet eGPU's Thunderbolt DisplayPort In Adapter to the iMac's Thunderbolt DisplayPort Out Adapter. If it works, then you would see that the iMac display is connected to the eGPU instead of the iMac's built-in GPU. Apple doesn't have any public API for doing Thunderbolt stuff. You would have to reverse engineer this path setting code and the DisplayPort MUX switching code.
I don't know
if anyone has tested if TB TDM works using an eGPU and if a single TB controller can handle the setup you describe.
TDM should work. Since the Mac has a built-in GPU and an eGPU, both connected to DisplayPort In Adapters of Thunderbolt controllers, the question is, which DisplayPort In Adapter will be chosen as the source of the DisplayPort data that will be sent to the iMac's DisplayPort Out Adapter?
The built-in GPU is connected to a DisplayPort In Adapter of a Thunderbolt host controller.
The BlackMagic or Sonnet Breakaway Puck GPU is connected to a DisplayPort In Adapter of a Thunderbolt peripheral controller.
Will TDM choose the DisplayPort In Adapter of the host controller or the peripheral controller?
Maybe it will choose the shortest path? For example, if you connect the Thunderbolt cable to a host Thunderbolt port then it will choose a DisplayPort In Adapter of the host Thunderbolt controller. If you connect the Thunderbolt cable to the eGPU, then it will choose the DisplayPort in Adapter of the eGPU.