As discussed in this Q&A, as of Mojave, Apple has deprecated the ability to lock the dock to one specific screen/position, e.g. the key position-immutable
is deprecated.
This question is asking for a hack/work-around to either (actually) lock the dock's position or (effectively) prevent the auto-dock-reposition based on scrolling the mouse.
It may be possible to accomplish this with Hammerspoon?