Lie in wait with a 'supersoaker' waterpistol. They hate that and it might be enough to deter them.
Are these your own pets or invaders? Our two terriers are 90% trained not to go on the veg garden and not to dig there, but the 10% of the time they forget their training is plenty to cause damage to our plot. They never defaecate in the veg garden as we always take them for a walk before working there.
We used to keep cats but when the last one died of old age a couple of years ago, we decided not to replace her. It's wonderful to have no cat faeces in the flower beds (she was always kept out of the high fenced veg patch) and the wildlife has come out of hiding too.
There are plastic mats of spikes you can spread over the surface, but I'm not sure how effective they are, or how expensive.
It's a real problem, and one with health dangers too. I hope someone comes up with some really effective answers for you.