The word such is used as a predeterminer. (Not concentrating on other uses of such, because they are not relevant here)
When it is used as predeterminer, we use a/an after such. We can also use such as a single determiner, without the need of any other determiner, such as a/an following it.
For example -
They are such idiots. [Here such is the only one determiner]
He is such a fool. [Here such is sued as a predeterminer, and a/an follows]
It was such a pity that you couldn't be with us.
We have had such awful weather lately.
So the bottom line is, we can use both - such a/an and such, like I have shown in example sentences.
Now coming to your negative sentence confusion with such.
The word no is used as a determiner - central determiner, that is. (The other use of no is not discussed here, as they are not relevant here)
Determiners are words which come at the beginning of the noun phrase.
There are three types of determiner: central determiner, predeterminer and post determiner. The order in which they occur in a sentence - predeterminer + central determiner + post determiner.
This is the reason we don't say five the all boys. We say all the five boys. [all - predeterminer, the - central determiner, five - post determiner]
No other pattern of occurrence of these three type of determiners are allowed.
When the central determiner precedes such, it's a pro-form modifier. Hence, no such idiot is correct.
But no such a idiot is incorrect.
Consider this -
I have seen green balls were there. Where are they? No, you are wrong. There is no such balls.
Here the word such is a pro-form modifier, replacing green - an adjective.
We can say green ball, but not green a ball, because an adjective can only modify a head noun in a noun phrase structure, it however can't modify a noun phrase.
This is the reason it's incorrect to say - no such a boy