Format a template using jinja2.
As of LangChain 0.0.329, this method uses Jinja2's SandboxedEnvironment by
default. However, this sandboxing should be treated as a best-effort approach
rather than a guarantee of security.
Do not accept jinja2 templates from untrusted sources as they may lead to arbitrary Python code execution.