Flush system cache does not work during installation of Drupal Profile
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 is _not_ active in the same thread -- e.g. it's OK to run when PHPUnit is doing setup/teardown because the statics/singletons/caches are essentially inert; but if one did this while running hook_civicrm_config or a Civi page-controller, then some active function on the call-stack may implicitly rely on them, so the behavior would be ill-defined.

Proactively initialize the settings (Civi::setting()-&gt;set($key, $value)) before activating the extension. Don't rely on the default values for the settings.
Try working with the SettingsManager (Civi::service('settings_manager')). This has its own flush() operation.


Since this is included in System.flush, I don't have high expectations... but it is imaginable that your use-case requires flushing with a different _sequence_ of operations.