The reform to the penal code applies to those who "reproduce and transmit messages or communications originating or allegedly originating from" the criminal groups.
El Salvador's Congress has approved sentences of 10 to 15 years for those who spread gang-related messages in the media, prompting journalists to raise censorship fears.
Tuesday's measure, which was requested by President Nayib Bukele, also targets those who "mark" their territories with acronyms — a practice that gang members use to threaten those who report them to authorities.
"When the Germans wanted to eradicate Nazism, they prohibited by law all Nazi symbology, as well as messages, apologies and everything aimed at promoting Nazism...Now we will do the same with gangs," Bukele said on Twitter.
El Salvador's journalists' association issued a statement expressing its "concern" about a "clear attempt at censorship".
The "gag" reform, as the group described it, "threatens with imprisonment the media and journalists who report on a reality that the current administration" of Bukele "seeks to hide".
It is a "new tool to criminalise journalistic work", the group said.
Cracking down on gangs
The deputy of the ruling party, Marcela Pineda, said the reform does not seek "to restrict freedom of expression" but to force responsibility "in the messages that are disseminated to the population".
The reform adds to a series of changes to the penal code approved by Congress to crack down on gangs, which the government refers to as "terrorists".
El Salvador declared a state of emergency 10 days ago following a weekend of violence that included at least 87 reported killings, which the government attributed to the Mara Salvatrucha (MS-13) and Barrio 18 gangs.
About 6,000 suspected gang members have been arrested since then, according to official figures; there are about 70,000 gang members in the Central American country.
Last week, Congress increased the maximum prison sentence for being a gang member from nine to 45 years.
The government also raised maximum prison sentences for children and will allow teenagers to be tried as adults for the most serious offences, and serve their sentences in adult prisons rather than juvenile detention facilities.
The office of the UN High Commissioner for Human Rights has expressed concern about El Salvador's approach to combating gang violence, pointing to "alleged cruel, inhuman or degrading treatment".
"In addition to the state of emergency, we are deeply concerned about certain amendments to criminal law and criminal procedure," said the office's spokesperson Liz Throssell.