Using a Raspberry Pi Zero W GPIO to unlock an electronic lock
The IRF520 will be OK for a 5V Arduino (see below for Rpi) based application, the max current 9.2A and voltage 100V are generously above your needs. The module you have indicated looks fine and is designed to drive DC motors so it may have an onboard flyback diode (I couldn't see it in the photo or spec). If you do need to add a diode nothing particularly special is required-an IN4007 will do the trick.
The Rpi has 3.3V GPIO so you need a MOSFET with a lower threshold. The IRL540 (2V threshold) should be OK here.