Apple Support addresses this very scenario:
What if I don’t have access to a trusted device or didn't receive a verification code?
If you're signing in and don’t have a trusted device handy that can
display verification codes, you can have a code sent to your trusted
phone number via text message or an automated phone call instead.
Click Didn't Get a Code on the sign in screen and choose to send a
code to your trusted phone number. You can also get a code directly
from Settings on a trusted device. Learn how to get a verification
code.
If you trusted device is your iPhone and you say that it's connected to your phone number, this is a good thing. What you will need is a (cheap) replacement phone that can receive calls/SMS (text messages). Depending on your carrier (i.e AT&T or TMobile) you can just move your SIM card to another phone to receive the call/text message with the verification code. If it's a carrier that doesn't use SIM cards (Verizon, Sprint), you will have to get them to activate the cheap phone for you.
Once you get the call/SMS, you can now validate your account to disable two-factor authentication.
If all else fails, you still have another option...
If you still can't sign in
If you can’t sign in, reset your password, or receive verification
codes, you can request account recovery to regain access to your
account. Account recovery might take a few days or longer, depending
on the specific account information you can provide to verify your
identity.