Current flow in the dynamo
If the dynamo is a brushed DC machine, that can work as either a generator or a motor, then yes, it can work either way round.

Connect the machine to a battery, and it will spin like a motor, at a speed determined by the battery's voltage. A small amount of power will flow from the battery to overcome the losses in the motor.

Load the motor to reduce its speed. The power from the battery to the motor will increase.

Drive the generator with a rotating force to increase its speed. Power will now flow from the generator to the battery, to absorb the mechanical power you're driving the shaft with, and to charge the battery.

If the generator is an AC machine followed by a bridge rectifier, then power cannot backflow from the battery to it. The bridge rectifier prevents current flow in reverse.