Tamping is considered something of a science, insofar as there are usually specific numbers attached to the pressure one is to apply. That's a worthwhile place to start, I think, but not ultimately very useful. Eventually, you just know. You tamp until you don't need to tamp anymore, until the espresso no longer gives way, until its a perfectly uniform and compact puck, ready to yield its treasure.
Just pay attention. The goal is not to smash the whole thing, or grind it all down. So don't be violent. Neither is the goal to apply a uniform amount of pounds per square inch. The goal is to get a good puck. So, tamp until you have a good puck. Trust yourself to know when this is. Gain this trust by careful and attentive practice. There is no other way.