Is it legal in football that a player scores a goal in penalty by creating a pass (in forward direction as per rules) to another teammate and get passed back and repeat the passes until they want to score the goal? (any defensive moves from the opposite team are neglected)
Yes, absolutely. There are essentially only two major restrictions on play after a penalty kick:
The player taking the penalty kick must kick the ball forward
The kicker must not play the ball again until it has touched another player.
So long as those restrictions are met, the ball is in play as in normal play and anything goes.