Hello Rik_ST,
We have some suggested steps to use your iMac as an external display with your MacBook Pro M1. First, be aware that you won't be able to use target display mode with your iMac since it's an unsupported model. Read more here: Use your iMac as a display with target display mode - Apple Support
You can connect your iMac wirelessly with your MacBook Pro M1. We'll use steps from this article: Use one or more external displays with your Mac - Apple Support
Connect the displays wirelessly
You can wirelessly connect your Mac to devices, such as another Mac and certain smart TVs, and use them as displays.
1. Choose Apple menu > System Settings, then click Displays in the sidebar. (You may need to scroll down.)
2. Click the pop-up menu on the right (below the name of your Mac), then choose your display.
If you have them connected via your cable, try the following steps for when the display isn't detected:
If your Mac doesn’t detect a connected display
1. On your Mac, choose Apple menu > System Settings, then click Displays in the sidebar. (You may need to scroll down.)
2. Press and hold the Option key, then click the Detect Displays button on the right.
You can also try putting your Mac to sleep and then waking it.
Reply back with any questions.
Take care.