Fix incorrect result for Base.invmod(<:Signed, <:Unsigned) (#58010)
MWE of bug:
```julia
julia> Int(invmod(1024, UInt(12289)))
5652
julia> invmod(1024, 12289)
12277
```
---------
Co-authored-by: Max Horn <max@quendi.de>
Co-authored-by: Lilith Orion Hafner <lilithhafner@gmail.com>