Digging is a natural dog behaviour and is very rewarding for them. Giving them a place where you are happy for them to dig will stop them practising the behaviour in areas that you don’t want them to dig up!
Fill a hard paddling pool with sand or create a “legal” mud digging area. Encourage your pup to dig in the sand and as they dig say the word “Dig”. Give them lots of praise. If they go to dig elsewhere in the garden, call them to the sand instead and say “Dig”. Reward them when they do so. Hide toys and treats in the digging area to keep your pup interested.