I have previously registered a UDF with hive. It is permanent not TEMPORARY. It works in beeline.
TEMPORARY
CREATE FUNCTION normaliseURL AS \'com.example.hive
It will work on spark on yarn environment however as suggested you need to use spark-shell --jars .jar not in hdfs but in local.
spark-shell --jars .jar