If a law or precept grants the judge the faculty to apply or not to apply a penalty, he is, without prejudice to the provision of can. 1326 § 3, to determine the matter according to his own conscience and prudence, and in accordance with what the restoration of justice, the reform of the offender and the repair of scandal require; in such cases the judge may also, if appropriate, modify the penalty or in its place impose a penance.
Source: Code of Canon Law (Vatican.va)