There is a third-party workaround product called Luna Display that might let you use that 27" 5K iMac screen as a second screen.
Astropad – Blog – How to Use Your iMac as a Monitor: A Step-by-Step Guide [2025]
"Like any product, Luna Display does have limitations and it’s not recommended for high-motion content. For example, I wouldn’t recommend using Luna Display for gaming or video editing.
Since Luna Display is squeezing a 5K display through a USB cable, when lots of motion occurs on-screen (like from video playback or moving a window quickly) the screen can temporarily become pixelated before it renders in at full resolution. "
27" 5K monitors which have the pixel density of your iMac are still relatively few in number and expensive. Apple wants $1599+ USD for theirs. For a while, only LG made a competing 27" 5K display. That's changed, and now there also are, or soon will be, 27" 5K (5120x2880 pixel) displays from Samsung, BenQ, Asus, and ViewSonic.
My advice would be that if you are interested in exploring the possibility of using Luna Display to salvage that nice 27" 5K screen, you still should pick out a good standalone hardware display for your Mac mini. Although large 4K displays aren't quite as nice as large 5K ones, there are more 27" – 32" 4K displays than you can shake a stick at, and some decent basic ones are fairly cheap ($300 – $400 USD, meaning you could potentially buy three 27" 4K displays to "max out" a new Mini for less than the cost of one 27" Apple 5K display).