Yes, but you still need a display to navigate the Mac mini and enable the option, there is no way to activate it with a single keyboard key press or from the M4 iMac directly. If the Mac mini does not already have a display, then you'll probably not be able to enable Airplay from it since you need to see its screen for that every time you want to access the Mac mini.
For what you describe your best option would be Screen sharing instead of AirPlay, since you can initiate that from the M4 iMac's Finder or the Screen Sharing app and see the Mac Mini's screen on the iMac.
click here ➜ Share the screen of another Mac - Apple Support
You'll still need a display connected to the Mac mini at least once to enable Screen Sharing if it's not already enabled. But after that, you can access the Mac Mini's screen from the M4 iMac directly.
click here ➜ Turn Mac screen sharing on or off - Apple Support