From my testing it seems like you cant do mathematical operations outside of setting a variable.
So when you do the $givenName.length()-2
in this block it wont work.
$givenName.substring($givenName.length()-2).toLowerCase()
I had success first determining the substring input value and then using it later like so.
#set($subLength = $givenName.length() - 2)$givenName.substring($subLenth).toLowerCase())
So in theory to fix your velocity it would look like:
#set($ln = $sn.substring(0,2).toUpperCase())
#set($subLength = $employeeNumber.length() - 4)
#set($empNumber = $employeeNumber.substring($subLength))
#set($subLength = $givenName.length() - 2)
#set($fn = $givenName.substring($subLength).toLowerCase())
$ln$empNumber$fn