To render a single field with the display setting of a view mode you can use the view()
method of the field:
Example for rendering the image the way it's configured in the node's teaser view-mode:
$build['image'] = $node->field_image->view('teaser');
Or the body as it's configured in the node's full view-mode:
$build['body'] = $node->body->view('full');
Or if you want to have more fine-grained control, you can programmatically recreate how Drupal is doing view-modes:
$display_options = [
'label' => 'hidden',
'type' => 'entity_reference_entity_view',
'settings' => [
'view_mode' => 'some_media_image_view_mode',
],
];
$build['image'] = $node->field_image->view($display_options);
You can figure out the type/settings by inspecting the HTML on the view-modes form (e.g. /admin/structure/types/manage//display/full ) or export the configuration and inspect the YAML files.