In general it is possible to do that (assuming the phone has an unlockable bootloader), but you can't do that for the exact same image from the manufacturer, because they don't provide the source for a lot of it.
You might be able to install a third-party, community-maintained OS, like LineageOS, though, if your hardware is supported. The downside is that I believe apps like Google Pay won't work anymore, since they require Google's SafetyNet attestation system to pass. Sometimes there are ways around that, but they always seemed like unreliable hacks to me.
You might be able to install a third-party, community-maintained OS, like LineageOS, though, if your hardware is supported. The downside is that I believe apps like Google Pay won't work anymore, since they require Google's SafetyNet attestation system to pass. Sometimes there are ways around that, but they always seemed like unreliable hacks to me.