Code snippet that can be used to disable form field in drupal 8.
function mymodule_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id)
{
if ($form_id == "user_register_form") {
$form['account']['notify']['#attributes']['disabled'] = 'disabled';
// or
$form['account']['notify']['#attributes']['readonly'] = 'readonly';
}
}