I think there are maybe two questions here.
If it’s about how to set middle gray value for a photo that doesn’t include a reference card, and you’re using the scene-referred filmic workflow, I’ve found this FAQ bullet point quite helpful. TL;DR is by using the color assessment mode alongside the gray theme, you should simply aim to match average brightness.
If you’re wondering how to visualize which pixels are currently at the middle gray value, I don’t think there’s an ‘out-of-the-box’ way to do that in darktable. I’ve created a preset for the ‘rgb curve’ module that only ‘lights up’ the middle gray values, so as I move exposure around, I can see what parts are at middle gray. I think this is a correct way to do this, since the values are at 50% lightness using the Lab color picker, and stay there when I switch back to using filmic. I’d also be interested if there’s a better way to visualize this. The same values can be parametrically selected using the gray slider and picking a narrow range that centers around 18.
rgbcurve_middle gray.dtpreset (1.1 KB)
Image credit: @BenBeau from this PlayRaw thread.
Alternatively, you could look into using something like a false color LUT to highlight regions based on lightness.