I believe it is not posible to use the panel templates in flask with server_document or server_session. This approach only use the bokeh layout, but it does not utilize the css or the html of the panel template, but it utilizes the css and the html you define in the flask template.
The solution I found was to embed the panel app in a iframe, as described here Distributed fiber optic sensors: panel multi app with flask
I am not sure if I understand the templating in the jupyter notebooks ?..