How do I darken new mortar in a brick wall to match the older mortar?
Universal dyes might do what you want.  The trick is having the patience to test them to final color at dryness  Here's one color brand (no association, haven't used them)

The source here (National Park Service) recommended against them (dyes), and they might diverge in color over time.  They suggested cleaning the surrounding area.

Diluted muratic acid brushing/power wash at a months's time would blend the old and new effectively (use protective gear/old cloths/gloves/goggles) hose down landscape plants beforehand)

Here's a tutorial for cleaning mortar off brick from Fine Homebuilding