Modify parent entity from within custom field formatter
You can do this from inside the field formatter.  Each of the $items passed into the viewElements method has a getEntity() method that will give you the entity.

class MyFieldFormatter extends FormatterBase {

  public function viewElements(FieldItemListInterface $items, $langcode) {
    $entity = $items[0]-&gt;getEntity();
  }

}


However, this is not recommended since it inverts the normal control flow. In normal situations, everything needed to render a field is a value on a column in the field itself.  Grabbing the entity is icky, but is definitely possible for strange edge cases.