This might work, but I think it is best to not tinker further if you already have a working script (especially one that you understand and can modify further if needed).
perl -pe 's/\[[^]]+\]\((?!https?)[^#]*#\K[^)]+(?=\))/lc $&=~s:%20|\d\K\.(?=\d):-:gr/ge'
Well, I’m not going to even try understanding the various features used in that
sed
command. I do know how to use basic loops with labels, but I never bothered with all the buffer manipulation stuff. I’d rather use awk/perl/python for those cases.