Is it possible to put, on a mentally ill person, a surveillance implant that detects said person's emotions and thoughts? This 'chip', 'implant' or other monitoring machine should be able to monitor movement, emotion, and thought.
Possibly. Your call when you build a setting.
In theory, the action of nerve cells is electrical and chemical, and could be tracked by a fine net of sensors in the brain. There are plenty of science fiction stories using that, making the mind-machine interface a familiar trope that can be used with little need for explanation or justification.
On the other hand, it is sufficiently not-there-yet that you can easily not have it in your setting if you don't want to. Simply says that it is too hard to do in practice, even if it could be done to something as simple as a frog or perhaps a roach.
No, because the brain is too spread out: the functions of emotions and thoughts are spread throughout the brain and occur both in the electrical impulses and in the chemicals released / absorbed. There are also "network effects" and the differences in interconnections that individuals have. Thus, an implant can't measure the totality of the brain's function. At best, we get some indications of major actions / emotions. The implants that are being used to control outside tools use rough control, not fine measurement. That is why they take a good bit of training to use.
Look at the range of ways that we are investigating brain functions. We use EEG, MRI, MEG, PET scans, etc. What this range of methods shows is that brains operate on multiple scales with multiple methods. It is interesting to see PET scans in response to a stimulus. Widely spaced areas of the brain light up together. That shows that what we consider to be one reaction is really multiple areas of the brain working together on the response. An implant would need to be able to measure activity over the whole brain, not just where the implant is placed. It would need to measure electrical and chemical behavior. We don't have many chips that can measure chemical. In short, our current technology is not capable of building one implant that can sample or measure the wide range of brain activity.
It is possible (because it has been done) to detect thoughts and emotions, using fMR imaging to detect specific activity patterns in the forebrain.
To do this with an implant, though, you need an extremely invasive implant, because you need to reach a significant portion of the frontal cortex as well as the rest of the encephalic mass. This raises a host of problems, from biocompatibility to the surgical procedure's difficulties.
Then, you need to analyse the gathered information to perform the decoding. That is going to require significant computing power, so, almost certainly, an external device.
You'd probably be better off to restrict your use case. For example, just an example: to prevent an insensate serial rapist from acting on their impulses, you need only to detect when these impulses do arise, and counteract them. The needed surgery (and analysis) would then be order of magnitude simpler and more economical, and could be packaged in a sort of "intracranial pacemaker".
Update: could it be done, patient unaware?
Definitely NOT. As I said before, the procedure would be nightmarishly invasive. The surgeons would need to place electrodes in a lot of places, and then calibrate them over a long period.
Barring unexpected progress in microtechnics, I don't expect such surgery to even be possible for at least thirty to fifty years.
The required computing power, assuming Moore's law keeps holding, will be implantable in the body - probably in the belly, there's too little space in the cranium - in some twenty years, at which point it will just cost a bomb. At that point, or even earlier, a much simpler signal decoding and analysis will give back arms and legs to amputees. Other ten-twenty years and we'll give back almost-normal sight to blind people (currently, we can do black and white over about sixteen pixels).
I have such a machine.
I have a phone in my pocket. Because I choose to use my phone this way, my family can track where I am with my phone. I set it up that way. And they can monitor my emotion because sometimes I call them up and tell them how I feel. I can tell them my ideas and sometimes I tell them the weird ones. Or I can tell those things to a well-meaning stranger who will listen to me talk about my troubles. I have the device and I use it to help me.
You probably have a phone too. If you think that people who care about you want to know, tell them! When you don't feel good, or you are worried, or thoughts are intruding on your life I hope you will use your phone to talk to someone. Maybe a therapist or someone on a hotline or maybe even your parents or siblings. Hearing things you think said out loud (by you!) makes them less scary, because they turn into words that can be shared. It is like turning on the lights when you think something is in the room. Things become clearer.
Half of reality is what you get because of where and when and who you are. The other half is what you make of it. Work on that second half. You are able to write down your thoughts in a forum like worldbuilding stack. That means you have control and that is good. Flex your muscle. Use your control over the half you have to put that other half where it can't hurt you. It will still be there, but you will be the boss of it.
You can detect emotions. The detection can be done because emotions are mostly chemical based. You feel better when you eat certain foods. There are anti-depressants, drugs that control (to some degree) emotions. Medicines are chemicals. Perfumes also effect moods. They are also chemicals. Endorphin, testosterone etc are chemicals produced by human body itself. They effect moods.
Future technology may be able to precisely identify and detect in time sudden surge of a chemical that lead to a suicide attempt within next ten minutes say, or a person getting angry enough to break furniture whatever. It would still be an indirect way to estimate current thoughts. Thats as far as one can expect to go with foreseeable technology.
Putting probes on head to detect electric currents to directly estimate thoughts wouldnt work because by its very nature everybody's brain has different wiring (connections between nuerons).
There is also Godel's Theorem preventing us (humans) understanding our brains because we are bound to use brains to understand brains and we dont have artificial intelligence yet.
Lets split it into a few sections to make it easier to consider.
Detailed thought detection
This requires a deep understanding of the brain and how the mind functions. This requires knowledge we do not have at this time.
I would rate this not possible in the next 10 to 40 years. Probably not reasonable for even longer then that.
Thoughts are occurring detection
Detection that the person is thinking/ has brain activity, is easier and doable today. But I would expect this to be nearly useless. as this will mostly be raw data points, not useful information. That is you could get cpu 80%, cpu 82%... but that's about it.
Being able to tell where the brain is active and a bunch of machine learning and bunch of questionnaires could probably start pinning down things like doing lots of balance work, now playing music(audio + muscle memory), now doing some symbolic thinking. That is, what general task category the person is doing might be possible.
All the strong emotions are broadcast into the body via hormones, neural transmitters etc. Lots of signals to pick up from various locations. An implant into practically anywhere could do this. Calibrating for the individual becomes one of the hardest things. Along with miniaturized sensors that can read the relevant compounds and their concentrations.
A basic implant to read emotions can be built today. The accuracy and completeness of emotion/feeling determination would be low. But being able to read off simple/basic emotions such as fear, anger, hunger, lust should be very doable.
There are existing off the shelf solutions(external) for this. That is you can buy a device that periodically says: I am here. Taking the "monitor movement" to mean a persons location.
Could in the far flung future a device be created to read detailed thoughts; Yes it is not strictly impossible. However there are many difficult obstacles and this is very unlikely to exist for a very long time.
Getting how busy is the brain, is possible, but probably not so useful. Perhaps able to pick up general activity type.
Emotion detection could be created much sooner as it is simpler and much less subtle.
It's called a 5G phone
There are a number of "5G" formulations, but the one desired by the Pentagon as the object of a no-bid contract - as opposed to the option discouraged by the Pentagon - is the one which is in the terahertz range. This is perhaps due to the many, many uses of terahertz in biological imaging - see this preprint references 12-16, or perhaps this paper about brain imaging with terahertz. Basically, you can detect blood with 5G radiation, so you can do imaging like fMRI (see LSerni's answer for a bit on how that relates - to explain a little beyond that, the phone would measure exactly which areas light up when a spam call says "QAnon" in the background, then measure when it lights up without an audio cue, and whether that is correlated with good or bad sentiments in your insula and limbic system). Well, not you - a spy apparatus that actually has rights and access to control the vast complexes of machinery hidden inside 'your' cell phone.
How is this done? Beamforming. The 'antenna' has many, many emitters that add up to a very narrow beam that only goes through one structure. This is integral to how the signal works. I should also note the apparent applications of this in having the phone or base unit deliver the energy all to one point in the brain to control future behavior. The applications are endless...
For reference, the "harmless" wavelengths associated with 5G are 6 GHz to 300 GHz. 6 GHz = 6E9 waves/second. Divide c = 3E8 m/s by that and get 1/20 m = 50 mm. Divide c by 300 GHz and get 1 mm. The Active Denial System (pain ray) is 95 GHz, right in the middle of the cell phone range.
Note that other applications, such as measuring differences in DNA or displacing transcription factors from particular regions of DNA, may be of more interest to some users.