Populate Taxonomy Term reference field in node
First, find the taxonomy term id by the term name as given below.  

function getTidByName($name = NULL, $vocab_name = NULL) {
  $properties = [];
  if (!empty($name)) {
    $properties['name'] = $name;
  }
  if (!empty($vocab_name)) {
    $properties['vid'] = getVidByName($vocab_name);
  }
  $terms = \Drupal::entityTypeManager()
    -&gt;getStorage('taxonomy_term')
    -&gt;loadByProperties($properties);
  $term = reset($terms);
  return !empty($term) ? $term-&gt;id() : 0;
}


Above function will return the term id and then pass this term id to your field like 

// Assigning the entity reference value.
if ($tid &gt; 0) {
  $entity-&gt;set('field_example', ['target_id' =&gt; $tid]);
}