The Technical Specifications for 2010 iMacs say that "27-inch models also support input from external DisplayPort sources." But no current Mac supports using any iMac – including a 27" 2010 iMac – as a Target Display.
iMac (27-inch, Mid 2010) - Technical Specifications - Apple Support
Use your iMac as a display with target display mode - Apple Support
Plan on needing to buy at least one real monitor for your M4 Mac mini. Note that monitor prices have fallen a little. In Late 2009, when the first 27" iMacs came out, a 27" 2560x1440 pixel monitor from Dell sold for about $1000 on sale, or $1200 when not on sale. If prices moved in sync with inflation, a monitor that cost $1000 in 2010 might sell for $2800+ today.
Instead, you can find some decent 27" 2560x1440 (2.5K) or 3840x2160 (UHD 4K) monitors which have IPS panels and 100% or near-100% coverage of sRGB for $300 – $350.
There are even some third-party 27" 5K monitors with street prices under $1000.