I had the same problem and worked through it with Apple Support for two hours over the course of 3 days. Here is what worked for me.
I. Delete iCloud Authenticators from Your Keychain
1. Open Keychain Access.
2. Select 'Passwords' from the Category area on the bottom left
3. Type 'iCloud' in the search field on the top right.
4. Delete all items that have your iCloud e-mail as the username.
5. Also delete any items that begin with 'IDS'.
II. Delete the Local Device ID from Your Keychain
1. While still in Keychain Access, choose 'All Items' from the Category area.
2. Type 'localdevice' in the search field on the top right.
3. Delete any item that appears.
4. Reboot your Mac.
III. Turn off Keychain Passcode
1. When the system reboots, try to disable iCloud just to see if it works. If not, continue to the next step.
2. Open System Preferences > iCloud.
3. Make sure you have an iOS device or another Mac logged in to iCloud with Keychain set to ON. You will need it for the next steps.
4. Click 'Options' next to Keychain and completely disable the security code so that everything in this dialog box is inactive/grey.
5. On your iOS device or other Mac, disable the same security code feature.
6. On your iOS device, now disable Keychain.
7. On your iOS device, try enabling Keychain again. You should see the option of resetting your Keychain. Reset it!
8. Now, on the troubled Mac, you should find that the Keychain option is disabled so that you can log out of iCloud.
The key in all of this is to reset your iCloud Keychain, but before we do that, we need to delete some of these keychain items that may be causing conflicts and communication failures with iCloud.
Please let me know if this helped you as it helped me.
Best regards