Naming a boy, 14, who plotted to behead police officers could cause him “serious harm”, a court said.