The @template annotation relates to a concept called Generics, which does not currently exist in PHP, but are a way of dynamically describing the contents of a parameter or return type that would be unknown until a class is instantiated or method called.
For PHP specifically, here is an article describing the doc blocks themselves and how to use them.
For the code you referenced, the template specifies T will be an instance of Extension\Extension. The $id parameter will be the class name for T, and @return says the method will return an instance of T.
Using the method would be something like $faker->ext(MyExtension::class), which would return an instance of MyExtension.
If you want to follow the rabbit, here is more on Generic Programming.