Buy a new one - you can't fix it.
Set it where you want and squeeze some silicone into the joint?
I'm guessing it's a ball and socket arrangement and either the ball slipped out of the socket or a section of the socket broke off eliminating tension on the ball.
If it slipped out one might be able to pop it back in but if it's a broken socket I would try aluminum foil tape. It sticks better than duct tape. It isn't as strong so several layers.
If you posted your bike make/model someone might have a parts/service manual and therefore a picture.
Good luck.