Two Factor Authentication for iCloud
To begin, open up System Preferences | iCloud. In the resulting window, click Account Details and (when prompted) enter the password for your Apple account (not the password for your macOS device). Click the Security tab and then click Turn On Two-Factor Authentication (Figure A).
Figure A
Enabling two-factor authentication.