Updated:

1. Turn it off for everyone

/gamerule locator_bar false

In 1.21.6 to 1.21.10 the rule is locatorBar. See the gamerule list.

2. Hide one player

/attribute @s minecraft:waypoint_transmit_range base set 0

A transmit range of 0 removes that player from everyone else's bar. Undo it with:

/attribute @s minecraft:waypoint_transmit_range base reset

Without commands, sneaking, wearing a mob head or carved pumpkin, or invisibility also hide you. Spectators never show.

3. Hide your own bar

/attribute @s minecraft:waypoint_receive_range base set 0

4. Change marker colors

/waypoint modify @s color red
/waypoint modify @s color hex FF8800
/waypoint modify @s color reset

Colors are random by default. Match them to team colors for team games. /waypoint list shows every waypoint.

5. Show a boss on the bar

/attribute @e[tag=boss,limit=1] minecraft:waypoint_transmit_range base set 500

Mobs can transmit too, so players within 500 blocks see the boss direction. See boss mob command.

6. Hide and seek

/attribute @a[team=hider] minecraft:waypoint_transmit_range base set 0

Seekers can no longer follow hiders on the bar. Reset it after the round. See hide and seek.

Troubleshooting

Check your command

The Command Error Doctor checks common syntax mistakes in your browser.