Service-based architecture is one of the major strength of Drupal 8. Drupal core and contrib provide lots of services to be used by other services, plugins or any other function. The flexible nature of Drupal allows overriding of services.
We can have different scenarios:
- Override Drupal Service without overriding arguments
- Override Drupal Service, overriding arguments as well
Now, both of them can be resolved using the approach discussed in https://www.drupal.org/docs/8/api/services-and-dependency-injection/altering-existing-services-providing-dynamic-services where we implement a class extending ServiceProviderBase and the alter() method.
A second way is decorating existing services: https://symfony.com/doc/current/service_container/service_decoration.html
But there is one more pretty handy way to perform the 1st task specific to Drupal. Let's find out that :).