The secret is called escaping. You need to place an extra set of square brackets around your shortcode [gallery]
and it will display as .
Also, double escaping works too: [[gallery]]
outputs [gallery]
.
There is also a Trac ticket on this topic.