Method 1
You could use a true sharp sign, ♯
, instead of the hash sign, #
. From the Wikipedia page on C♯:
By convention, a hash sign is used for the second character in normal text; in artistic representations, sometimes a true sharp sign is used: C♯.
Here ## C♯
produces
C♯
Method 2
Alternatively, (at least on this site) just put a space after the last #
, for example ## C\#
produces
C#
Note that Pandoc seems to handle # C\#
correctly (try it).