After testing on Tim's suggestion.
It does not work.
Have not tried yet.
It works after calling Civi::service('settings_manager') on the last tasks before install_finished task is called during Drupal installation.
Haven't done that, but if the focus is on manipulating the content of the settings, then one of these might help:
Try adding calls to Civi::reset() and/or CRM_Core_Config::singleton(TRUE,TRUE) to clear out any statics/singletons/thread-local caches.
Civi's headless unit-tests do this (via CiviTestListener). Note that one should only do it while Civi logic ...