This is about a related aspect of the question - ie not "how to do it" but "is this effect that I am trying to emulate really done this way?". Learning how to do what someone else has achieved is good. Trying to copy something which wasn't actually done the way you thought it was can be "annoying".
In some cases,
it may be claimed to be done in-camera but in fact be done using post-processing, or
the camera may be applying adjustments which affect the result.
If so, the user may not be aware of such effects or may be using them to advantage.
Quick and useful test - Increase Gamma substantially so the image is pale and very washed out overall (as in example below). Now inspect the "black". Much can be learned.
The example below at left was copied from Stack Exchange question
How do I get a really black background?
as an example of claimed in-camera processing.
While this is conceivably the case, simply increasing the Gamma level 'somewhat' brings up artefacts and main-image boundary conditions which strongly suggest post processing.
- If true black level (0, 0, 0) is present in the image, as it is here in the "black" areas well away from the central subject, then increasing Gamma will bring up anything that is not truly black, while leaving true black still as true black).
There are relevant comments at the end under "Comments on image:" , but I suggest you read the following first.
Near black pixels in the black regions adjacent to the model's hair could be due to light falling on individual hair strands or groups of hair such that light levels very near to black were returned. However, the low level pixels all along the length of the shoulder and upper arm cannot be explained in this manner. If you look at the original image these can be seen as non black areas. Conceivably these could be caused by lens flare or other optical effects, or by unwanted in-camera processing from eg a selective contrast enhancing mechanism such as Nikon's 'Active D Lighting'. D-Lighting and other mechanisms which adjust light levels in subareas in images can create boundary effects which are not in the original. A well documented and very visible example of this is shown here Nikon's "Active D-Lighting's" dirty little secret
But the impression I gain is that some form of 'fill' or black level cutoff has been used with a "reach" or "radius" of more than just the adjacent pixel. In the case of the model's shoulder & arm, the large bright areas to the right has affected pixels in what is mean to be completely black causing a "graded" edge. Again, this could have been done in-camera, but gives the impression of having been applied subsequently.
Notice the area of black just below and to the left (as viewed) of the model's chin. This 'suffers from' a similar proximity-to-brightness grading effect with only a very few pixels in the area actually being black. That this area should not be true-black is entirely reasonable as the area contains shoulder and hair with perhaps a peep of background, but the grading effect is clearly seen.
Note: This image is subject to imgur & stack exchanges's licence terms as long as the original was uploaded legally.
Comments on image:
Pixel peeping (or a good eye as shown) reveals that this image has been heavily and non expertly manipulated out of camera. No camera, and no automated editing process would do some of the things that have been done. So any claim that the background black is achieved in-camera are suspect (at least) especially given the factors mentioned above.
Look at the pupil of the model's right eye (on our left). The top of the pupil is truncated and it seems that a block may have been pasted in.
Her mouth has either been pasted on or significantly manipulated. This can be clearly seen even as presented in the original image (eg dark thin loop at top of mouth and more). A block of visibly different - material extends from the left 2/3 of her mouth to part way up her nose. No software in or out of camera would do this (or, if it did, you should bin it immediately).
Her left eyebrow has significant editing on the upper inner half.
Other images which appear to have a fully black background in fact do not have one as can bee seen by increasing Gamma. In some cases the gradations visible lend credence to the appearance of the image being untouched. In others, just the opposite.