Sensor replacement, as done by a regular/authorized service center, will very likely be a module replacement - an assembly made of the sensor, a PCB, and some mounting hardware will be replaced as a unit.
Replacing a sensor as an actual component in that assembly would require someone (professional or enthusiast) very skilled in component level electronics repair. We are talking at least 0.25 Rossmanns of skill here. Theoretically, such a technician could fit a lower or higher grade of the same component (IF that component is sold binned/graded), or a reclaimed component from used or defective hardware. Also, they could indeed fit a similar but not identical part using the same pinout and protocol, or even make wiring changes (or a new PCB) to accomodate a part different in pinout but identical in protocol. Someone that skilled would probably proudly offer that service honest and above board.
This leaves the possibility of the spare part being a reclaimed assembly from an otherwise broken or discarded camera (hopefully not: stolen camera!), or a factory reject (which a reputable camera maker is unlikely to give away or sell intact, so it would be, excuse the pun, a half-inched sensor), or a sensor that another repairman swapped out as suspect or defective. In the first case, as long as that is done transparently, it would actually not be a bad deal. The second case would be worst, you would get bad quality and potentially own stolen property.
Theoretically, someone could also undertake to refurbish sensors that were swapped due to damage to the optical filters (IF that assembly allows economically replacing them).