Do we have an option to change/override the drupalsettings variable which is defined by some other module through our custom module?
You can alter the drupalSettings with the hook &quot;hook_js_settings_alter&quot;:
function hook_js_settings_alter(array &amp;$settings, \Drupal\Core\Asset\AttachedAssetsInterface $assets) {

  // Add settings.
  $settings['user']['uid'] = \Drupal::currentUser();

  // Manipulate settings.
  if (isset($settings['dialog'])) {
    $settings['dialog']['autoResize'] = FALSE;
  }
}

For more information see: https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!theme.api.php/function/hook_js_settings_alter/8.9.x
I checked the code and the theme hook is run after the module hook. So if you really want to be last. Add the hook to your theme.
web/core/lib/Drupal/Core/Asset/AssetResolver.php:
$this-&gt;moduleHandler-&gt;alter('js_settings', $settings, $assets);
$this-&gt;themeManager-&gt;alter('js_settings', $settings, $assets);