This is a very big stretch of the imagination and the technology to do so does not exist and most likely never will. But, adapting noise cancelling technology to cancelling the waves produced by earthquakes could be considered.
A system to do so would require an earthquake monitoring system coupled with a wave & strength analysis system that would then produce an out of phase wave pattern to cancel out the earthquake waves.
Some of the problems with this would be the response times required & how to generate a out of phase wave system of equal magnitude to the earthquake waves. Extreme care would be needed so that the out of phase wave generator did not cause a similar amount of damage, or more, than the earthquake waves.
Also, the out of phase wave generator would need to be able to produce wave patterns at extreme short notice, repeatedly & possible continuously to ensure immediate responses.
The wave generator would also have to produce waves of extreme complexity in three dimensions from pulse waves to shearing type waves.
To ensure fast analysis times of complex wave patterns, quantum computers (which currently do not exist) would need to be used.
Such a system would be complex and expensive.