Singletons and mocks usually don't mix very well. If the factory call is a static one, substituting the singleton with a mock may result in unpredictable behaviour if other unit tests use the singleton. This is because subsequent requests for the object will also return the mock.
Of course, the best solution to the problem is to have a factory instance injected in your class, so that you can mock that instance in your test to return your mock config instance.
If that is not possible (and quite often it is not), another simple way to solve the problem is to add a delegating factory method in the class you want to test and then override that method to return the mock in your test case, like this:
This approach has proved to be quite useful in several cases when you need to mock an object which isn't injected to your class.