No. Target Display Mode went away when the first 27" 5K Retina iMac came out in Late 2014, and never returned. Apple also added restrictions on it which mean that Macs released in 2020 or later (such as your M3 MacBook Air) do not support using ANY iMac as a Target Display.
Reference: Use your iMac as a display with target display mode - Apple Support
-----
There is a lower-quality method of using one Mac as a second display for another, called AirPlay to Mac – but your 2017 iMac is too old to act as an AirPlay Receiver. (You might be able to AirPlay in the other direction – using your M3 MacBook Air as an AirPlay screen for the 2017 iMac.)
Reference: Continuity features and requirements for Apple devices - Apple Support
-----
There are third-party workarounds such as Luna Display (Astropad) and Duet Display. These are not as good as a hardware-supported connection to a 27" 5K Apple Studio Display. From an article on the Astropad site: "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."