canada
There are specific hate-related offences at ss. 318, 319, and 430(4.1) of the Criminal Code. And for all offences, when an offence was motivated by hate, that motivation is an aggravating factor on sentencing (see s. 718.2(a)(i)).
None of these offences or aggravating factors are dependent on the accused not being a member of the target group.
For example, the aggravating sentencing factor only requires "evidence that the offence was motivated by bias, prejudice or hate based on race, national or ethnic origin, language, colour, religion, sex, age, mental or physical disability, sexual orientation, or gender identity or expression, or on any other similar factor."
And for a further example, s. 319(2) makes it an offence to wilfully promote hatred against any identifiable group by making statements. This only requires that the statements made actually promoted hatred of the identifiable group and that the accused held a subjective realization (or wilful blindness) about the likely result of their actions.