Custom latex command/operator/function

Is there any way to define custom functions? for example, \sign is by default not a function and it would be nice that we can define functions like this

Joplin uses katex for the latex rendering. I think katex supports macros. You can look here as a place to get started