Demons that Jesus cast out of people did speak to Jesus and knew who He was etc.
I'll share how I think this story about demons is actually about adoption of us Christians, and it relates to the parable of the Prodigal Son and to our own adoption as sons of Abraham. We are prodigals returning to a Father. We are impure having wasted our inheritance and returning with nothing, and the gospels warn against treating us as foreigners.
Luke 8:29 specifies that this possession (which Matthew refers to as a demon) is an 'Impure spirit'. Impurity refers to something which causes a person to be like the nations and cut off from Israel, so this man who is possessed is like the prodigal son. He, like the prodigal son, is impure but his impurity is taken away just as the prodigal son's impurity is and just as ours is.
It is significant that Luke specifies this is an impure spirit. 'Spirit' is English but comes from Greek 'Pneuma' which is similar to the Hebrew for breath
'Nephesh' (I meant to say 'Ruach' which is the ancient Hebrew for breath). These are words used to describe psychological things such as thinking. Breath is a way of thinking or a soul or a mindset. In the Law of Moses you have to have have a circumcised heart. An impure spirit is referring to the opposite, hence the gospels are dealing with the idea of doing everything right physically keeping the law but having the wrong heart. That is the possession they are talking about.
They actually are also saying that having a right heart is the point, and I know this because Jesus points out that all of the law can be summed up as "Love the LORD and love your neighbor as yourself." He also says "The letter kills but the spirit gives life." Always with Jesus being righteous is about having the right spirit, right thought, right heart, and frequently the temple is the object of his criticism.
The possessed man is supposed to represent those in Israel (or perhaps among Christians) who have a particular mindset that Jesus says is wrong. They are spiritually dead, and so the possessed man dwells among the graves. They also are judging others, who they think are like the Samaritans or who are like the Romans. Jesus would say to them to first take the log out of their eye before judging another. He would say to them to not judge, or they will be judged more. He would say that we are like like children who must be allowed and that the kingdom of God will have us in it. All of this works together with the general messages of the gospels. So for Jesus there are two kinds of impurity. There is the person who is impure, and there is the person who thinks he is better.
In the Law: impurity causes one to be cut off from Israel. In the gospel these demons of impurity are plural but the impure spirit is singular. A spirit is a way of thinking, and this way of thinking causes many impurities. Christians have to live by 'The spirit' which is the opposite of an impure spirit. The gospel is talking about our adoption into Israel and is talking about how some might object and that they shouldn't object. It is criticizing a big brother attitude against those not in Israel or not in our own group, we are considered to be the prodigal son or the big brother. We have spent our inheritance on impure things and come back to the Father with nothing, or we have done everything we are supposed to and don't like it when other people get equal respect. Now that impure spirit is driven away and so we are to be accepted. The big brother must accept us and remove the anger from his heart, the judgment that we have soiled ourselves and shouldn't be allowed into the family. That is what the gospel is saying.
So it is probably not talking about the demons in the OP. It is using them as an example but is not confirming whether they actually exist.