Chastity is a necessary prerequisite for Self-Realization. This is expounded in many of the scriptures. In Patanjali's Yoga Aphorisms, it is said that the first stage of Yoga is the practice of Yama and Niyama (do a search on Hinduism SE, these have been defined in prior questions). One of the practices of Yama is perfect chastity in thought, word, and deed. He further says in II. 38:
By the establishment of continence energy is gained.
What is this energy? Swami Vivekananda says in his book Raja Yoga which includes his translation of the Yoga Aphorisms with his commentary (Complete Works, V1 p 169-170, and available here under Raja Yoga subsection The Control of Psychic Prana - http://cwsv.belurmath.org/volume_1/vol_1_frame.htm):
The Yogi alone has the Sushumna open. When this Sushumna current opens, and begins to rise, we get beyond the sense, our minds become supersensuous, superconscious — we get beyond even the intellect, where reasoning cannot reach. To open that Sushumna is the prime object of the Yogi. According to him, along this Sushumna are ranged these centres, or, in more figurative language, these lotuses, as they are called. The lowest one is at the lower end of the spinal cord, and is called Mulâdhâra, the next higher is called Svâdhishthâna, the third Manipura, the fourth Anâhata, the fifth Vishuddha, the sixth Âjnâ and the last, which is in the brain, is the Sahasrâra, or "the thousand-petalled". Of these we have to take cognition just now of two centres only, the lowest, the Muladhara, and the highest, the Sahasrara. All energy has to be taken up from its seat in the Muladhara and brought to the Sahasrara. The Yogis claim that of all the energies that are in the human body the highest is what they call "Ojas". Now this Ojas is stored up in the brain, and the more Ojas is in a man's head, the more powerful he is, the more intellectual, the more spiritually strong. One man may speak beautiful language and beautiful thoughts, but they, do not impress people; another man speaks neither beautiful language nor beautiful thoughts, yet his words charm. Every movement of his is powerful. That is the power of Ojas.
Now in every man there is more or less of this Ojas stored up. All the forces that are working in the body in their highest become Ojas. You must remember that it is only a question of transformation. The same force which is working outside as electricity or magnetism will become changed into inner force; the same forces that are working as muscular energy will be changed into Ojas. The Yogis say that that part of the human energy which is expressed as sex energy, in sexual thought, when checked and controlled, easily becomes changed into Ojas, and as the Muladhara guides these, the Yogi pays particular attention to that centre. He tries to take up all his sexual energy and convert it into Ojas. It is only the chaste man or woman who can make the Ojas rise and store it in the brain; that is why chastity has always been considered the highest virtue. A man feels that if he is unchaste, spirituality goes away, he loses mental vigour and moral stamina. That is why in all the religious orders in the world which have produced spiritual giants you will always find absolute chastity insisted upon. That is why the monks came into existence, giving up marriage. There must be perfect chastity in thought, word, and deed; without it the practice of Raja-Yoga is dangerous, and may lead to insanity. If people practice Raja-Yoga and at the same time lead an impure life, how can they expect to become Yogis?
Krishna also expounds continence as necessary for Self Realization in Chapter 6 of the Gita, especially verses 5-15. Verse 14 says:
He should remain seated with a placid mind, free from fear, firm in the vow of a celibate, and with the mind fixed on Me by controlling it through concentration, having Me as the supreme Goal.
The Brahma Sutras also make reference to chastity as being necessary. Brahma-Sutras (3.4.17) says:
And (knowledge belongs) to those who are celibates; indeed (this is so) declared in the scriptures.
The commentary then gives several Upanishad references for this verse. And further in verse 3.4.19:
They are to be practiced, Badarayana thinks; for the scriptural text refers equally to all the stages of life.
This verse says that continence is not only for sannyasins, but also for other asramas of life. Several Upanishad verses are also given in support of this verse in the commentary.
What is a Maharishi? It is simply an honorific given to some yogis (and sometimes just given by themselves to themselves!). Maha means great, rishi means seer of mantras.
Paramahamsa means great swan. It refers to a person who has attained the highest realization.
Can a person who matrubate be a maharshi?
Maharshis don't need to masturbate unless they want.