They detect whether a testlead is plugged in and when that state does not match the selected range a signal is buzzed and displayed.
The implementation of the detection is dependent on the manufacturer. These two methods are very common:
electrical - splitting the input jack contact and detecting a current across both halves caused by the plug shorting them together
optical - shining light through the input and detecting the interruption of the light beam caused by the plug
Electrical (split input jack)
With the split input jack they can send a signal to one of the jack halves. When the testlead is plugged in, the signal is shorted over to the other halve and can be detected by the microprocessor.
See EEVblog episode #99 at 20:55 (direct download and other infos here)
Dave shows the input jacks of a Extech multimeter and explains why they do what you ask for.
This is the board viewed from the top:
(Source: EEVblog episode #99)
This is the board viewed from the bottom:
(Source: EEVblog episode #99)
Here's another example of a Keysight multimeter:
The mechanical construction is quite different but the jack is split too. Dave shows this a second later.
Source: EEVblog episode #832 at 17:10 (direct download and other infos here)
Optical
This type of input alert uses a (infrared) LED sending a lightbeam through a transparent input jack. When the plug enters the jack, the lightbeam gets interrupted.
In case of the Fluke multimeter this type of input alert is used to ensure the waterproofing.
See EEVblog episode #64 at 9:30 (direct download and other infos here)
Dave shows the board and input jacks of a Fluke 28 II multimeter.
This shows the LED and photodiodes on the board:
(Source: EEVblog episode #64 info page)
This shows the transparent jacks of the case:
(Source: EEVblog episode #64 video)
so I want to build a circuit to do this and mod it on my multimeter.
I don't think that you should do that.
Input protection on a multimeter is not trivial (Dave's videos on multimeter tear downs explain much about that). With bodging some input alert into the multimeter you risk to disturb necessary spacing and clearance.
If the processor does not have a firmware that supports input alert adding such a modification is not done with just some wire. Not to speak about splitting the input jack.
Note: there might be other ways of input jack signalling like buttons or light barriers, but I don't think they're as reliable as real junctions.