I don't think that's possible with the way display servers and window compositors interact in Linux (as opposed to Windows where the two are coupled much more tightly). However you can post-process the image to add a drop shadow similar to that added by the window compositor.
Find a suitable drop shadow filter
I found and played around a bit with ImageMagick’s -shadow
filter and came close with these parameters:
convert :input.png \( +clone -background black -shadow 50x5+2+2 \) +swap -background none -layers merge +repage :output.png
As a bonus the shadow uses transparency for image formats like PNG (at 32 bit colour depth) that support it. Result from the example in your question:
You can find a more in-depth explanation on the shadow filter in the Examples of ImageMagick Usage.
Combine the filter with a screenshot tool
We can write a small script to combine the above filter with a screenshot tool like gnome-screenshot
:
#!/bin/bash
printf -v filename '%s/screenshot %(%F %T)T.png' "$HOME" -1
tmpfile="$(exec mktemp --tmpdir --suffix=.png screenshot.XXXXXXXXXX)"
trap 'rm -f -- "$tmpfile"' EXIT
gnome-screenshot "$@" -f "$tmpfile"
convert ":$tmpfile" \( +clone -background black -shadow 50x5+2+2 \) +swap -background none -layers merge +repage ":$filename"
…or use what’s already there
It appears the GNOME developers had a similar idea and integrated a shadow filter into their screenshot tool:
gnome-screenshot --window --border-effect=shadow
This creates almost the same visual effect as above:
You can unbind the default keyboard shortcut for screenshots and create an identical shortcut for a custom command like the one above.
For more info see gnome-screenshot(1)
.