That is exactly how to solve the problem - just put it in a directory on your search path above the IPT directory.
Note that this also effectively disables the IPT imerode function, so if you ever need to use any capabilities of that tool that are not in your own code, it is no longer available to you. To restore access to the old imerode, you would need to change the search path, or delete or rename your version.
You may get warning messages from MATLAB, that your function steps on existing code. At least when you use it initially, but that warning seems to go away after the first use.
disp('The sky is falling')
The sky is falling
One other way to temporarily recover use of the original tool is to use builtin, although I think that will only apply to actual builtin tools like chol. Toolbox functions seem not to be recognized by builtin.
L = builtin('chol',2)