I did this on a Devuan system, which is basically Ubuntu without systemd. This not a well-known distro, so your mileage may vary, but I think it will all work as described on
Apache two-factor (2FA) authentication with Google Authenticator based on Time-based One-Time Password (TOTP) or HMAC-based one-time password (HOTP) Algorithms. - itemir/apache_2fa