Resetting a configuration object to "factory settings"
Core does not provide such an API, not in a way that is easy to use.

There is a contrib module that provides this, but it's probably too complicated to rely on for a specific use case.