Short answer: four defaults keys stop the Dock being resized, moved, emptied or hidden. They are stored per account, so on a family Mac with separate logins they have to be set in each one.
Screen Time will not do this. It controls which apps can be opened and for how long, and has nothing at all to say about the Dock.
Most versions of this problem involve a machine strangers use. The people changing the Dock on a family Mac live with you. They are not doing it on purpose, and you cannot exactly revoke their access.
Which changes what a good answer looks like. The goal is to make Tuesday look like Monday.
Screen Time and Family Sharing are Apple's parental controls, and they are good at what they cover: which apps can run, for how long, what content is allowed, and when the Mac goes quiet at night.
None of those controls touches the Dock. There is no Screen Time setting for the Dock's size, position, contents or auto-hide. The two solve different problems and work fine together.
defaults write com.apple.dock size-immutable -bool true
defaults write com.apple.dock position-immutable -bool true
defaults write com.apple.dock contents-immutable -bool true
defaults write com.apple.dock autohide-immutable -bool true
killall Dock
Each one grays out the matching control in System Settings, so it cannot be changed from the interface at all. They survive a restart, a sleep and a macOS update.
They are stored per account. At home, families often miss that each account has its own settings. If the family has separate logins, running these in yours does nothing in anybody else's, and each account needs its own pass. If everyone shares one login, once is enough.
To release one, remove the key:
defaults delete com.apple.dock contents-immutable; killall Dock
Every key with its type is in every Mac Dock defaults command.
If the Mac currently has one login that everybody uses, giving each person their own is the larger fix, and the Dock is only part of what it settles: separate Desktops, separate Downloads, separate browser history, separate everything. The Dock then stops being a shared surface at all, and each person's stays as they left it.
The cost is that you configure the locks more than once. The cost is smaller than it sounds, and you pay it once.
There are two ways to hold these settings and at home only one of them is right.
If you want the middle ground, Still Dock can require Touch ID to turn a lock off, so nobody passing the keyboard can casually undo a lock, and you are still one fingerprint away from changing it.
macOS adds a section of recently used applications to the right of the Dock. On a shared login it fills with whatever the last person opened, and it changes every day whether or not anyone touched anything.
defaults write com.apple.dock show-recents -bool false
killall Dock
The four locks do not remove it. It is a separate setting, covered in how to stop recent apps appearing in the Dock.
The free Still Dock for iPhone and Apple Watch app lets you check and switch these locks from your phone, so re-locking the Dock after a change doesn't mean walking back over to the family Mac.
No. It stops the Dock changing. Restricting what can be installed or opened is Screen Time's job, and the two are fine together.
Yes, if the family has separate logins, because these are per-account preferences. A profile pushed by an MDM can cover a whole device at once, but an MDM in a house is a heavier tool than the problem deserves.
With the ordinary locks, yes, if they find the Terminal commands. With a profile, not from Terminal, though it can still be removed on purpose in System Settings. Neither is a safe, and neither is meant to be.
No. They live in the account's preferences, so an update leaves them alone. They also survive Migration Assistant to a new Mac.
Anything set in one login does not appear in another, so set the locks in the accounts your family actually uses. If an account is one macOS clears between sessions, the settings go with it.
The commands are identical, but the situation differs. See a classroom Mac, a library or public Mac, or the shared Mac guide for the general case.