AWS Cognito has a 2 types of MFA: SMS and Authenticator App verification.
For SMS you can use custom web-hooks which is intercepts SMS messages and sending it to custom Email box (as mailhog as example) via API. Then you can get message content with API and use the code in your tests.
For Authenticator App verification you can use something like that: https://maddevs.io/writeups/automating-googles-authentication/
I think this method works, but in my practice I have not had to work with Authenticator apps.