How to display the source code of a shortcode in a code block?

Just like this:

And when I do this it renders the shortcode in the code block.

Use this syntax to include shortcodes calls within your code examples:

{{</* foo */>}}
{{%/* foo */%}}