If you want to use code fences in a highlighted block of code in a (Github-flavoured) Markdown document you cannot just use code fences themselves to highlight the code.
Instead you have to use three tildes like this:
~~~html ``` <script src="foobar.js"></script> ``` ~~~
This will then look like this:
``` <script src="foobar.js"></script> ```
I have used this both in hugo and jekyll.