DC motor as a generator as well as a motor in a car
The thing you're asking for is 4 quadrant control.
What that means is, the motor and controller can implement 4 different modes:



Motor going clockwise, controller applying clockwise drive (forward)




Motor going anti-clockwise, controller applying anti-clockwise (reverse)




Motor going clockwise, controller applying anti-clockwise drive (braking forward)




Motor going anti-clockwise, controller applying clockwise (braking reverse)



In addition to that, when doing braking, an appropriately-designed motor + controller combo can implement regeneration (transferring energy to the battery) instead of just shedding kinetic energy as heat.
More here: https://www.pmdcorp.com/resources/type/articles/get/regenerative-braking-part-i-steady-state-analysis-article
That all said, you really need to buy the motor and controller as a system, because different traction motor types (BLDC, induction, brushed, etc.) have different driver needs for drive and regen capability.
BONUS: Different traction motor types used in cars.
https://circuitdigest.com/article/different-types-of-motors-used-in-electric-vehicles-ev