When an action is brought in the name of the state against a principal or surety in a recognizance entered into by a party or witness in a criminal prosecution, and the penalty is judged forfeited, the court may forgive or reduce the penalty according to the circumstances of the case and the situation of the party on any terms and conditions it considers just and reasonable.