Yes, you are right. a custom scalar function would require you to write an expression as you mentioned, and also add a SQL facade over it incase you want to use it in a SQL query.
Yes, unfortunately there isn't a good reference in the docs for writing expressions currently. You can take a look at
https://github.com/apache/druid/blob/master/core/src/main/java/org/apache/druid/math/expr/Function.java#L426 which contains a small abstraction for functions which take 2 arrays as input. I'd be help incase you have any questions related to it