To change Entities fields its better use MODULE_ENTITY_presave()
function (more info in docs).
In this case that you need change a node field use this function:
function hook_node_presave(Drupal\Core\Entity\EntityInterface $entity) {
$entity->set('title', 'Updated title');
}