[DependencyInjection] Added support for closure as a factory method

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| License       | MIT
| Doc PR        | n/a

I've detached closure's part from #11953. Furthermore, there is no SuperClosure dependency anymore, because I'm not sure if I have to create bridge package by myself.