Programmatically update node image field (using URI of the image) and get URL in twig
You have to create a file for the image first before you can add it to the node.

use Drupal\node\Entity\Node;
use Drupal\file\Entity\File;

  $node = Node::load(1);
  $uri = 'public://image.jpg';

  // check first if the file exists for the uri    
  $files = \Drupal::entityTypeManager()
    -&gt;getStorage('file')
    -&gt;loadByProperties(['uri' =&gt; $uri]);
  $file = reset($files);

  // if not create a file
  if (!$file) {
    $file = File::create([
      'uri' =&gt; $uri,
    ]);
    $file-&gt;save();
  }

  $node-&gt;field_image[] = [
    'target_id' =&gt; $file-&gt;id(),
    'alt' =&gt; 'Alt text',
    'title' =&gt; 'Title',
  ];

  $node-&gt;save();