How to show a field value instead of the node title for nodes displayed through an entity reference field?
No code necessary, Drupal has built-in features for this:


Create a new view mode singlefield for the referenced content type foo, showing only the field value
Optionally, create a very minimalistic template for this node--foo--singlefield.html.twig
In /admin/structure/types/manage/foo/display change the view mode of the host entity reference field to Rendered entity, using view mode singlefield