How to sign in to iCloud without verification code sent to other device?
I found a workaround using SMS. In a web browser, sign in to the Apple Store and when it asks for a verification code, click the "I didn't receive a verification code" link. Select to receive the code by SMS. Now, instead of using the code you receive by SMS to sign in on the Apple Store, you can use it to sign in on your Macbook.