Pass custom variable to an entity reference templete
Create two view separate modes for your entity reference, one for each boolean value. In preprocessing, modify the view mode of the entity reference depending on the value of the boolean field.

This is a code example I'm using for paragraphs to change the view mode of a referenced media entity:

function mytheme_preprocess_paragraph__image(array &amp;$variables) {
  $paragraph = $variables['paragraph'];

  if ($paragraph-&gt;hasField('field_imageratio')) {
    $imageViewMode = str_replace('media.', '', $paragraph-&gt;field_imageratio-&gt;target_id);
    if (isset($variables['content']['field_image']['0']['#view_mode'])) {
      $variables['content']['field_image']['0']['#view_mode'] = $imageViewMode; 
    }
  }
}


I think you can largely reuse the logic above, field_imageratio should be replaced by your boolean field, field_image should be replaced by your entity reference field.