A nuclear explosion can cause an earthquake and even a sequence of aftershocks. However, the earthquakes induced by the explosions have been much smaller than the explosion, and the sequence of aftershocks produces fewer and smaller aftershocks than an earthquake of similar size. The relative amplitude of the waves can also be an indicator of an explosion and not of a natural earthquake. The bottom line is that you can't fake the seismic signature of an underground explosion, people will be able to know whether or not you tested a bomb, and approximately how strong it is.
Underground detonations of nuclear weapons can be detected as earthquakes for a simple physical reason. In both cases, whether rocks break in an earthquake or during an explosion, very strong forces act quickly inside the Earth. This leads to intense shaking of the rocks around the hypocenter, which in turn generates elastic waves. They can travel thousands of miles and are detected by sensitive seismometers.
Seismometers have long been routinely used to verify nuclear test treaties, and scientists have become increasingly confident that they can detect even small evidence and distinguish it from natural earthquakes.