Put a group around the text you want to keep and refer to that group by number in the replacement pattern:
re.sub(r's([?.!"](?:s|$))', r'1', text)
Note that I used a r''
raw string to avoid having to use too many backslashes; you didn't need to add quite so many, however.
I also adjusted the match for the following space; it now matches either a space or the end of the string.
Demo:
>>> import re
>>> text = "This text . Is to test . How it works ! Will it! Or won't it ? Hmm ?"
>>> re.sub(r's([?.!"](?:s|$))', r'1', text)
"This text. Is to test. How it works! Will it! Or won't it? Hmm?"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…