Currently if you want to add a new twig filter or extension from your phpbb extension, you basically need to replace \phpbb\template\twig\twig with your own class.
This is because of Twig environment will be locked inside the constructor after setting the lexer.
Replacing the original class or service by your custom one causes a lot of issues
1) you need to keep your class in sync with each phpbb version
2) only one extension works at any time, making twig extensions incompatible with each other
To fix this I propose adding the following events:
The first event called something like "twig.extend" called inside the contructor before $this->twig->setLexer($lexer); This event needs to send $this->twig as the parameter.
And the second event "twig.context" called inside get_template_vars() to allow extensions to inject extra context variables.