Expanding on your own findings, you can use screencapture
in additional ways:
screencapture -SW ~/Desktop/screencapture.jpg
-S in window capture mode, capture the screen not the window
-W start interaction in window selection mode
Now you need to click on a “window” that is big enough to capture the whole screen – the Desktop.
When capturing the main screen, move your mouse to the screen edge where your dock is located and click (even clicking on the Dock, visible or not, captures the whole screen).
Capturing a screen without the Dock, you need to find an area where the Desktop is visible.
You can capture a rectangle that matches your secondary screen. This is more useful if your monitor layout doesn't change.
For example, given two full-HD monitors, main on the left, you could use this to capture a rectangular area of 1920x1080 starting 1920 pixels to the right (where your secondary monitor starts):
screencapture -R1920,0,1920,1080 ~/Desktop/screencapture.jpg
-R<x,y,w,h> capture screen rect