You can use Two Factor Authentication (2FA) on Mastodon by going to:
Preferences > Account > Two Factor Auth > Click "Set Up" and follow the instructions
It is compatible with TOTP authentication apps such as Aegis Authenticator, Google Authenticator and lots of others.