I think "The judge says that it is not legal" is a more direct translation of this sentence because it includes "que." El juez dice que no es legal. = The judge says that it is not legal. vs. El juez dice, "no es legal." = The judge says, "it is not legal." I agree that we do not need "that" in the sentence, but since the "que" is in the Spanish sentence, I think the "that" should be in its English translation.
That being said, I think you are confusing the uses of the word "that" in your explanation. In the sentence "the judge says that it is not legal," the word "that" is a conjunction connecting two clauses: "the judge says" and "it is not legal." It is not really necessary. But when the word "that" is used to replace something (beating a suspect), it is being used as a pronoun. You could use it to create a standalone sentence: "That is not legal." You can't leave it out without putting back in what it replaced or using another pronoun.
Blusens, I hope that helps some. That is all I have to say.
The police officer says, "I will beat a confession out of him."
The judge says, "(that) it is not legal."
The judge says, "beating a confession out of him is not legal."
it = beating a confession out of him
that = beating a confession out of him
Note how the "it" was dropped. To add a "that" before the "it" is just redundant here. "that" refers to the same thing that "it" does here.
Eso/ese/esa/aquella/aquel you probably usually always keep the "that". It is with the conjunction "que" where "that" may often be optional in the English. It is when "that" is a conjunction or it is simply redundant that you can drop it.
Because the "that" would have to be translated as «eso». Your sentence in English would be equivalent to "The judge says that that is not legal," where the first "that" = «que» and the second one is «eso». In English, the first "that" (the demonstrative adjective) can be dropped, but it cannot be so easily omitted in Spanish.