You have signed with your only Apple ID address say example1@gmail.com in Mac system preferences > iCloud .
Open a new tab ( use command and T keys ) and open www.icloud.com click don't fill up the password and click on use a different Apple ID .
Click on forgot Apple ID or password .
If the account is set up with two factor authentication enter the trusted number and click on continue .
Click on show notifications that appears on the top right corner of the screen , System preferences opens automatically , click on reset password and follow the up coming instructions .
The other way is click on using your device is the easiest and safest way ....on the right side of the screen shot .
If you click on don't access to have this Mac , the above screen shot will appear , you can reset the password , if the account was set up with secondary authentication in which three answers and questions , date of birth , rescue mail address and password is set , the article LAC Allen has posted will work .
Please mention which Mac version are you using .