A kicking team player on a scrimmage kick (punt or field goal) can only catch a ball that is still in the air if there is no receiving team player in position to catch the ball.
On a free kick (kickoff), the ball must be grounded for the kicking team to recover it.
The foul for both is kick-catching interference, 15 yards. The receiving team can elect to take the result of the play, an awarded fair catch and 15 yards from that spot (the spot where the foul took place), or 15 yards from the previous spot and replay the down.
For a scrimmage kick, if a receiving team player touches the ball while they are clearly beyond the neutral zone, a kicking team player can catch the ball in the air legally. Note: if the ball is blocked or partially blocked in or behind the neutral zone by a receiving team player, this touching is ignored.
For a free kick, if a receiving team player touches the ball anywhere on the field, a kicking team player can then catch the ball in the air legally.
This all can be found in NFHS Rule 6-5-6.