Yes, walking distance will count even if you are capturing a Pokemon.
Egg progress will also be made in the following scenarios (credit to this Reddit post from theSilphRoad:
- Having a pokestop selected on your screen
- Having a different egg hatch mid walk. I'm referring to the screen with a picture of an egg that says "Oh?"
- Having your menu open while walking. I was on the egg selection screen for testing. What is interesting is that the distance values don't actually update until you close the screen and reopen it, but the distance logged was correct.
- CATCHING A POKEMON. I'm very excited to report this as it's been speculated for a long time that catching a pokemon while walking won't log your location correctly. That is wrong. I entered a battle/cutscene whatever you want to call it prior to walking. Didn't interact with it for the entire 1 km. At the end I caught 2 of the pokemon and ran from the other two. All four attempts gave me full distance logging.
From observation, egg and buddy distance progress are calculated the same way (delta vector calculated each minute), so buddy distance should be unaffected by these actions as well, so long as you are walking less than 10.5 km/h.