I saw this guy catching a shiny dugtrio and it used dig and the ball still hit while he was underground. This was in Gen 2 and now I’m curious when this was changed.
the video in question (around 6 minutes in)
Generation I ... Pokémon can be caught in the semi-invulnerable turn.
Generation IV onward Pokémon cannot be caught in the semi-invulnerable turn.
So they can be caught while using Dig, Fly, Dive, ect. in Generations 1, 2, and 3.
Source: Bulbapedia