Anything is possible...
You would inject the fuel directly into the cylinder, like a diesel or a gasoline direct injection engine. The problem is gasoline is made to resist ignition at high pressure and temperature. First you would have to get the cylinder pressure high enough at the point of injection (I don't know how high of the top of my head). The way to do this is increase the compression ratio, likely higher than that in a diesel engine, although turbo charging would help. Then the best case would be at full load. As load dropped, so does cylinder pressure, and hence compression ignition would be less likely.
Second, you have to inject the fuel into this high pressure environment. To inject into a high pressure environment, you would need even higher pressure in the fuel system. This is not an easy task. Right now DI Gasoline engines are pushing around 120 bar, but with much difficulty.
If you took care of those problems, which are not impossible, then it should work.
Bottom line... It is not impossible, just impractical.