SerializerFactory::newSerializerForObject optionally takes a SerializationOptions object. EntitySerializer however requires an EntitySerializerObject.
Scribunto_LuaWikibaseLibrary calls newSerializerForObject with no options set, which causes a fatal error when trying to instantiate an EntitySerializer.
The issue however is more general: If SerializerFactory takes a generic options object, but some of the serializers require a specialized options object, the caller of the factory function would have to know in advance what kind of object will be constructed.
In fact, any knowledge about the needs and requirements of any of the objects the factory may create essentially renders the factory pointless. For the factory to be useful, it must only request very generic information from the caller.