But you can enable System Preferences > Sharing > Screen Sharing on the M1 mini and interact with it on the screen of the iMac as the main computer with the iMac's keyboard and mouse. Two-way drag and drop is available. Both Macs need to be on the same network segment, and you ensure that the iMac's Firewall > Firewall Options… is configured to accept the Virtual Network Computing (VNC) network connection from the M1 mini:

Click on your Desktop to wake the Finder, and press shift+cmd+G to open the Go To Folder dialog. Copy/paste the following into it:
/System/Library/CoreServices/Applications
which will open a Finder window on that folder location. Drag and drop the Screen Sharing.app from that location onto your Dock. After the M1 mini has had time to boot, launch the Screen Sharing application and enter the computer name of the M1 mini. You can also see this name on the iMac in the Finder window sidebar under Locations > Network. By example, I want to screen share the Mac odin7 and I enter odin7.local in the Screen Sharing application.
When you are done with Screen Sharing, you can shut down the M1 mini from its screen on the iMac, and/or Close the Screen Sharing connection, before quitting Screen Sharing.