Prevent deletion of specific icons from dock
I don't think it is possible to lock specific icons.

To lock all the icons go to Terminal and type:

defaults write com.apple.Dock contents-immutable -bool yes


Press enter then type:

killall Dock