Four people have been injured after an ax- and knife-wielding teenager went on a bloody rampage on a train in southern Germany.