I can find a lot of article on how to use a previous version of the iMac as a second monitor.
This is the only article you need:
Use your iMac as a display with target display mode - Apple Support
It has the proper hardware and macOS requirements for the now-dead Target Display Mode.
The amount of totally incorrect post-processes horse fodder regarding TDM on the internet is staggering. Remember, most internet articles are not reviewed for correctness. Editors are rare. There is probably more spurious information on the internet about Target Display Mode than there is about the Loch Ness monster and a flat Earth. TDM has been incorrectly attributed as doing everything from supporting any video device ever made to parting the Red Sea!