This configuration setting is easy to get with the following snippet.
\Drupal::config('system.site')->get('name');
Buy me a drink 🍺 to keep me motivated to create free content like this!
"Thanks for this amazing book, it is wonderful, throughfull explained and pedagogically crafted with care. Great Book". Camillos Figuera (Colombia) reviewed Learning Drupal 9 as a framework.