If all you are given is a function handle, and you are not permitted to examine the source code, then it is not always possible to determine whether a function is invertible.
Consider for example
testfun = @(x) x + (x == 37.9123325183) .* 12.0876674817
which returns its input except for 37.9123325183 for which it returns 50 instead.
Without some tool for disassembling the implementing expression, you would have to have tested with exactly that magic value in order to have observed a result different than you expected.
Or here is another one: write a function that returns its input **unless* the number is odd and the sum of the factors of the number including 1 but excluding the number itself, add up to the number, in which case return -1.
Is this function invertible? No-one knows. A lot of research has gone into it over the centuries, but no-one has been able to prove that Odd Perfect Numbers do not exist (the above function is invertible except at odd perfect numbers.) Therefore even having access to the source code is not enough to be able to tell whether the function is invertible.