How to change the value of a field in its preprocess method? I am trying to figure out Drupal 8's $variables array ...
So I have a MYTHEME.theme file, complete with a working MYTHEME_preprocess_field() function. (I know it works because I use it for other fields that need customization.)
Right now I'm focusing on the title of an article displayed on the front page of my site. I can access it with the following code.
if ($variables['field_name'] == 'title') {
    $title = $variables['element'][0]['#context']['value'];
    // ...
}

What I want to do is replacing all instances of ® (the registration mark) with &lt;sup&gt;®&lt;/sup&gt;. However, setting this value in the array to something else does not change it on the site.
Is there something I'm missing? A few sources I found said to alter (or add) the #markup element in the array, but there's a death of information about this online.
How do I change the value of a field? This seems like it should be something basic and easy to do.
In Drupal 8 front page is a view called frontpage if the view is not modified it should show: "Content" by default (instead of fields).  If so the following can be applied to change each node title

function THEMENAME_preprocess_node(&amp;$variables) {
  //for views that show: "Content" (not fields)
  if($variables["is_front"]){    
    $variables["label"][0]["#context"]["value"] .= " end of title";
  }
}