How to use hook_form_alter in the .theme file to alter the form fields?
If you want to alter a specific form, and you know the ID, use hook_form_FORM_ID_alter() rather than the generic version:

function THEMENAME_form_user_register_form_alter(&amp;$form, FormStateInterface $form_state, $form_id) {
  // Add alterations specific to the user registration form
}


Make sure you clear the cache after renaming the function.