As you said you have to use the Symfony Yaml component.
For example you can access the "src" data :
$yaml = Yaml::parse(file_get_contents($this->container->get('kernel')->getRootDir() .'/config/common.yml'));
$srcData = $yaml['main']['schred']['viral']['image1']['src'];
Here, your data is accessible = 'https://i.stack.imgur.com/ElkSn.jpg'. Next you can change value and update your file :
$yaml['main']['schred']['viral']['image1']['src'] = $yourNewValue;
$new_yaml = Yaml::dump($yaml, 5);
file_put_contents($this->container->get('kernel')->getRootDir() .'/config/common.yml', $new_yaml);
Hope this can help you