Your New York City bus or taxi may soon be able to sense the movement of vehicles and the timing of traffic lights within a several-block radius as part of a trial program to reduce road injuries and deaths.

As part of a $25 million pilot program, 8,000 vehicles will be outfitted with special devices that can communicate with one another, as well as with roadside sensors, traffic signals and app-enabled smartphones.

The...