I have a simple solution to add brotli to your apache server wide configuration without templates.
add
<IfModule mod_brotli.c>
AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/xml text/css text/javascript application/javascript
</IfModule>
to a file named brotli.conf in /etc/apache2/mods-enabled
I prefer the Apache2 solution to the Nginx solution because if something goes wrong with the Brotli module of apache, it will not crash the web server. The broli module of Apache2 is a default package of the Linux distro. So, it is already tested to work with your version of Apache 2. Anyways, if it does not work, it will not crash thanks to the ifmodule tag.