That depends on the gun. Call the maker and ask.
A Ruger should be able to be dry fired till your finger falls off. I have a .44 Redhawk that has been dry fired at least 4,000 times. The trigger on that gun is smooth as glass now.
I dry fire my Glocks like it is my job.
Beretta told me not to dry fire the 92FS so I didn't. I also hated the trigger in that gun...
If you break a firing pin, having it replaced is a small price to pay for the DIY trigger job the gun will have and the muscle memory that you built up with that trigger.