Despite a wave of protests against the so-called judicial reforms, Mr Netanyahu on Thursday said he would do "anything it takes" to restore unity in the country.
But Attorney General Gali Baharav-Miara disagreed in a letter addressed to the Prime Minister.
"The legal situation is clear: you must refrain from any involvement in initiatives to change the judiciary, including the makeup of the committee for the appointment of judges, as such activity is a conflict of interest," she said.
"Your statement last night and any action you take in violation of this matter is illegal and tainted by a conflict of interest."
Police fired water cannon at demonstrators blocking a motorway in Tel Aviv on Thursday. So far, 92 people have been arrested during the demonstrations.
Mr Netanyahu is on trial on corruption charges which he denies.
He also said his hands were tied regarding legislation passed by parliament limiting the circumstances surrounding the removal of a prime minister.
The letter followed Ms Baharav-Miara's earlier warnings that Mr Netanyahu must stay out of his coalition's push for a judicial overhaul because of what she deemed a conflict of interest arising from his trial.
In a message distributed by the ruling Likud party, an unnamed source close to Mr Netanyahu denied the Prime Minister had broken any laws or conflict-of-interest agreements in his statement and said it had no repercussions on his personal affairs.
The source said it was necessary for Mr Netanyahu to try to reach a wide consensus during a time of national crisis that carried implications on the country both domestically and abroad.
Mr Netanyahu's religious-nationalist coalition has been pursuing changes to the judiciary that would give the government sway in choosing judges and limit the Supreme Court's power to strike down laws.
Proponents say the plan would rein in Supreme Court overreach and restore balance between the branches of government.
Critics say it would weaken the courts, endanger civil liberties and harm the economy.
The proposed plan has sparked weeks of nationwide protests and drawn concern among the country's western allies.
Mr Netanyahu was greeted by shouting and whistling from hundreds of protesters outside No 10 Downing Street on Friday, as opposition to his judicial proposals followed him to London.
Mr Netanyahu shook hands with British Prime Minister Rishi Sunak on the steps of No 10 and is also due to meet Britain's Home Secretary Suella Braverman.
Protesters could be heard shouting "Netanyahu go to jail, you can't speak for Israel", surrounded by police and metal barricades.
The demonstrations were organised by British Jews and Israelis under the banner "Defend Against Democracy" to voice opposition against the judicial reforms. Dozens of people waved Israeli flags and banged drums.