Short answer: Finder and the Trash are fixed in the Dock by macOS and cannot be removed. For every other app, run defaults write com.apple.dock contents-immutable -bool true; killall Dock in Terminal. Icons can then no longer be dragged out, added or reordered.
To change the Dock again, run the same command with false.
Finder always sits at the left end of the Dock, or the top when the Dock is on a side. The Trash always sits at the other end. Neither has a Remove from Dock option, and dragging them out does nothing. So if Finder is all you worry about, it is already safe.
Every other icon can be dragged off with a puff of smoke, moved by a stray drag, or removed with Options, then Remove from Dock. On a Mac other people use, that is how a Dock slowly loses its apps.
Open Terminal from Applications, then Utilities, and run:
defaults write com.apple.dock contents-immutable -bool true; killall Dock
With the lock on:
To unlock:
defaults write com.apple.dock contents-immutable -bool false; killall Dock
The lock is stored per user, so set it while logged in to the account you want locked. Its siblings for size, position and auto-hide are in lock the Mac Dock with Terminal.
Lock the Dock once it holds what you want. To start from Apple's set, see restore the default Dock apps. To stop macOS adding recently used apps on its own, turn off Show suggested and recent apps in Dock in System Settings, then Desktop & Dock, or see stop recent apps in the Dock.
If icons shift while the lock is on, the cause is usually somewhere else: a running app appearing and leaving, a profile from IT rewriting the Dock, or a restored backup. Mac Dock icons rearranged themselves helps you tell which.
Still Dock from stilldock.com has the contents lock as a switch in the menu bar, beside the size, position and hide locks. It restarts the Dock for you and can ask for Touch ID before anyone unlocks it, which helps on a family or shared Mac. The contents lock is part of Still Dock Pro. The App Store version locks size, position and hide, and does not include the contents lock.
No. macOS keeps Finder in the Dock at all times. You can hide the whole Dock, but Finder stays in it.
No. It only covers the Dock. Removing an icon from the Dock never uninstalls the app, and locking the Dock does not stop someone deleting an app from Applications.
Yes. The setting stays until you set it back to false or reset the Dock with defaults delete com.apple.dock.