Your dog passes the hallway mirror, sees a moving shape, and barks. We cannot assume they recognize the image as themselves. The reflection may be puzzling or alarming, especially when it appears suddenly in a dark window or a large mirror.
Cover the mirror temporarily or close off the route if your dog is rehearsing frantic barking. Keep them away from glass they could crash into. If this reaction is new, happens in many places, or comes with confusion or changes in vision, ask your veterinarian for an assessment. Do not hold the dog in front of the mirror to prove there is nothing there.
Start farther away
At a distance where your dog can notice the reflection and still respond to you, reward a glance back or calm movement past it. Then leave. Keep sessions short. Over several days, move a little closer only when your dog stays loose and comfortable. If they bark, freeze, or refuse food, return to more distance and make the exposure easier. Changing lighting or covering part of a reflective window can reduce the surprise while training.
Some dogs investigate briefly and move on, others will need the reflection removed from their routine for a while. Both are fine. A successful plan is one where they can move through the house without getting frightened, not one where they must stare calmly into a mirror. After making the mirror easy to avoid, the everyday dog-training habits guide can help you practice calm choices in ordinary settings. Do not make the reflection a test.
Sources: VCA Animal Hospitals: Do pets know who their reflections are?. VCA Animal Hospitals: Reducing Fear and Stress with Desensitization and Counterconditioning.