Was able to sign into iCloud on the mac using Google Chrome, but not Safari. Was not able to click Account Settings or anything else. The difference here was that was able to use text verification code as other option for 2 factor authentication, and same with below.
Was able to sign into iCloud on Android Chrome, then going into Account Settings led to signing into Apple ID website. From there, going to list of devices, the same mac with the previous OS was listed! Decided to remove this and restart the mac. After waiting for a couple of minutes, was able to start receiving auth codes through text.
The first time you enter password and get error message asking for code to be entered. You have to wait a bit, get the code, and try signing in again with format: yourpasswordcode, no space or other character in between. Then, upgrade proceeds.