How to render a soy template(from servlet) to wep-panel to display custom warning message

There are different ways to load the JS file, or rather, the web-resource on the page.

You can change the value of <context>prmc</context> in your web-resource definition to match the context of the pull request page that is bitbucket.page.pullRequest.detail in Bitbucket 7+
https://developer.atlassian.com/server/bitbucket/reference/web-resource-contexts/