You cannot use a regular expression pattern in a replacement pattern. {...}Does not copy text shot in a group 1 n times. To achieve the desired result, you must use the lambda expression or the callback method in re.sub:
import re
s = 'gh3wef2geh4ht'
s=re.sub(r"\d", lambda m: m.group() * int(m.group()), s)
print(s)
See a Python demo
Note that you do not need capture groups here, since all matches are already available in group 0.
m curren, m.group() - , int(m.group()) - , int. , 3 , "3" * 3 .