In answer to your query, I wish to tell you that though the freedom of expression under Article 19(1)(a) of the Constitution of India is one of the most important freedoms available to us, it is not absolute. Article 19(2) lays down certain restrictions like protection of sovereignty and integrity of India, maintaining public order, friendly relations with States etc. This means that if there is a threat to the public order, then the authorities can take necessary action to ensure that public peace and tranquility is maintained. Section 144 of the CrPC gives the power to the District magistrate of an area to put such restrictions which are necessary to ensure peace and maintenance of public order. Now, in answer to your query, if section 144 is in force in the city, it means that the exercise of the freedom of speech is restricted and since Ram violated the orders, he can be punished, and in this case, he won’t be able to invoke his freedom of speech and expression.
However, if the restrictions imposed under Section 144 are arbitrary, unreasonable and excessive, the restrictions can be put aside by a competent court. Various recent judgements of the Hon’ble Supreme Court have stressed that the restrictions cannot be excessive and must not encroach upon the fundamental rights of the people in the veil of maintaining public order.