iMac 18,3 with dual external 5K monitor I would like to run a iMac 18,3 (Radeon Pro 580, i7 4.2 GHz) with two external 5K monitors (LG 27&quot; 27MD5KL).
In Apple's description (https://support.apple.com/kb/SP760?locale=en_US) I found:

Two Thunderbolt 3 (USB-C) ports with support for:
DisplayPort
Thunderbolt (up to 40 Gbps)
USB 3.1 Gen 2 (up to 10 Gbps)
Thunderbolt 2, HDMI, DVI, and VGA supported using adapters (sold separately)


However, this document also states that two 5K external displays are not supported:

Simultaneously supports full native resolution on the built-in display
at 1 billion colors and:
One 5120‑by‑2880 (5K) external display at 60Hz with support for 1 billion colors, or
Two 3840-by-2160 (4K UHD) external displays at 60Hz with support for 1 billion colors, or
Two 4096‑by‑2304 (4K) external displays at 60Hz with support for millions of colors


Is there anything I could do to run two external 5K monitors? E.g. replace the iMac's graphic card or use an eGPU?
According to Apple, your iMac supports the following as second displays:

This model can simultaneously support the internal display at full native resolution and up to one 5120x2880 (5K) external display at 60 Hz with support for one billion colors; two 3840x2160 (4K UHD) external displays at 60 Hz with support for one billion colors; or two 4096x2304 (4K) external displays at 60 Hz with support for millions of colors. It supports both extended desktop (second workspace) and video mirroring (internal display duplicated on the external display) modes.

This means that only one 5K external monitor is supported. Two 4k monitors are supported however. I suspect this is due to the throughput of Thunderbolt, which is 40Gbps. A 5k monitor requires 28 Gbps alone. Also, you can not daisy chain the video connections, so you will need a thunderbolt dock with either displayport or HDMI port connectors for the monitors.
In response to questions below:
A Thunderbolt dock doesn't change the throughput of Thunderbolt or the Mac, it just adds additional connections. So, the dock will not allow two 5k monitors. It only provides additional connections. Now, perhaps your iMac already has two Thunderbolt/Displayport connections on the back to support the 4k monitors (not sure). If not, this is the role of the Thunderbolt dock, so you should purchase one with the needed connectors (they are all different so consider wisely).
An eGPU can drive your desired 5k monitors, but you will have to research the available eGPU options to find support for your configuration.
Note that the biggest limitation in this is the cable and connectors: Apple introduced 5K in iMac first, because Thunderbolt 2 only supported 20Gbps, which is not enough bandwidth for 5k, so they built the monitor into the system and created a sort of dual Thunderbolt 2 connection inside.
Thunderbolt 3 introduced 40Gbps, allowing 5k (Thunderbolt used mini-displayport connections and now usb-c style connections). Displayport connections (minidisplayport on Macs can support 5k with some displayport1 and all displayport2, which is on the Mac. For HDMI connections, HDMI 1.2 can support 1080p, with HDMI 1.4 needed for 4k. To get 5k, you need to have support for, and a cable that offers HDMI 2/2.1. Even then, most systems get 5k by compressing the signal.
So to get dual 5k on your system, you will need to use Thunderbolt to an external GPU, and then either Thunderbolt or HDMI 2.x from the eGPU to the Monitors, which means you need the proper monitors as well.