To escape the dollar sign inside a string literal, use the backslash character:
"\$"
To escape it in a raw string literal ("""..."""
), the workaround you provided is indeed the easiest solution at the moment. There’s an issue in the bug tracker, which you can star and/or vote for: KT-2425.