If you’re using your Apple ID to reset your password, then yes, you need an internet connection. However, if you’re using the Recovery Mode or a separate Admin account, no internet connection is necessary.