If the batter safely reaches first base and all runners advance one base as a result of the play, then the illegal pitch is cancelled. All play stands and there is no further penalty.
If the batter and all runners do not advance at least one base, then the offensive coach has the option of either the result of the play or to enforce the illegal pitch penalty. The penalty is a ball added to the batter's count and any runners on base are advanced one base.
That penalty is ASA. If they're going by LL Rules, the only penalty is either a ball on the batter or, if the ball was put in play, no penalty if the batter & any runners advance one base & the offensive team elects to take the result of the play. If there are runners on base & no play, it's just a ball on the batter & base runners do not advance.
So the answer depends on the rule set. Most middle school I know of usually go by LL Rules.
That penalty is ASA. If they're going by LL Rules, the only penalty is either a ball on the batter or, if the ball was put in play, no penalty if the batter & any runners advance one base & the offensive team elects to take the result of the play. If there are runners on base & no play, it's just a ball on the batter & base runners do not advance.
So the answer depends on the rule set. Most middle school I know of usually go by LL Rules.
New York is kind of an oddball state when it comes to school ball. Most states that I know of use NFHS (National Federation of State High School Associations), even for middle school. However, numerous sections of NY, for whatever reason, decided not to go with NFHS. Some areas even use ASA for their high schools.
If this were NFHS, the penalty would be the same - ball called on the batter, all runners advance one base.