You could do something like:
source <(
env -i bash -o noglob -c '
source path/to/my.sh &&
for f in $(compgen -A function); do
printf my-
typeset -f -- "$f"
done'
)
Which starts a new bash instance (so without any function defined as long as there's no $BASH_ENV or exported function in the environment which we make sure of with env -i), loops over the functions that are defined after sourcing the file and outputs their definition with my- prefixed to the name.
The result is fed via a pipe to source using process substitution.
A zsh equivalent could be something like:
source <(
zsh -fc '
source path/to/my.sh &&
(( $#functions )) &&
printf "my-%q() {\n%s\n}\n" "${(@kv)functions}"'
)
($functions is the special associative array that maps function names to their definition, ${(kv)functions} expands to both keys and values of that associative array, @ and double quotes are to preserve empty elements (a function name can be any string including the empty string in zsh)).
perl -i.bak -pe 's/^\s*(\S+)(\s*\(\)\s*\{)/my-$1$2/' my.sh. Or does this have to happen on the fly?