You probably could technically, but don't waste time trying....
The boat should be taken out of the water, the drive removed, then the engine....
On an I/O anyway.....
I wouldn't want to try it.
Pulling the engine out may be ok on the water but trying to get it back in and set in there right could be a problem especially with the rocking motion of being on the water. The drive can stay in with no problem.
even if you could pull the motor in the water with the drive still attached, you must pull the drive to align up the motor with the gimble bearing when re-installing the new motor.