According to the lexer inside of Typst’s source code, an identifier is valid if it follows the Unicode standard uax31 and, additionally, Typst allows _ as a starting and continuing character and - as a continuing character.
As for how users should name their variables and functions, the standard seems to be kebab-case. Referencing a variable with just an underscore won’t work since that is probably reserved for explicitly nameless variables.