Here's yet another answer that incorporates suggestions by @Sweeper and @Benzy Neez, with some additional subtleties.
To summarize:
- As suggested by others, a mask is not needed since you can simply set the width of the progress bar based on the indicator horizontal location, simplifying logic and layout.
- Instead of a ZStack, it uses a single HStack with a Capsule and layered/ordered background modifiers that build the track and the progress bar, for the sake of showing another way of doing it.
- Added a tap gesture allowing tapping anywhere on the track to advance the progress.
- When dragging the indicator, the grab location should be at the center of the indicator (this is even more apparent the wider the indicator is).
- Some minor cosmetic options.
- See code comments for additional details.
