Hello, I think I was having a similar problem. I contacted Apple Support, and learned...
Short answer: In order to use the 2-factor verification process, your device has to be running the most up-to-date operating system. So if your Macbook is running any OS other than High Sierra/10.13, you have to turn off the 2-step verification process.
Longer answer: To turn off the 2-factor verification process, you need at least 1 good device that is successfully linked to your iCloud account (iPhone, iPad, etc). You also need the naughty Macbook you're trying to connect to your iCloud account, and it must have a working web browser and internet.
- On your Macbook, open your web browser and go to "Manage Your Apple ID" at
https://appleid.apple.com/#!&page=signin
Sign in using your Apple ID and password.
The webpage should then show empty squares for you to input a verification number.
- Your good iCloud-connected device should notify you, saying a different naughty device is trying to login
with your Apple ID.
Choose "Allow" on your good device.
It should then provide a verification number.
- Enter the verification number into the webpage on your naughty Macbook.
You should then be able to view your Account details online.
Scroll down to the "Security" section, and click on the "Edit" button.
Select the option to turn off the 2-factor verification process.
Once you do this, it will prompt you to choose 3 security questions instead.
- Once you've switched to the security question mode, go back to System Preferences on your Macbook.
Select the iCloud, and enter your Apple ID password.
Your Macbook should now be a good device that is successfully linked to your iCloud account.
Upgrade or downgrade your OS as you desire.
I was running OS 10.9.5, so I upgraded to 10.13, and chose to turn the 2-factor verification back on.
If you choose to have your Macbook run an older OS, you must leave the 2-factor verification off.
Good luck!
-Amber