I am still technically married, I am just waiting for my divorce to get finalized, but I met someone whom I really wanted to marry and his visa had expired and for him to stay here legally, I need to marry him, however, there is still the pending divorce. Can I marry this man? And will it be valid and can he apply for a permanent visa?
You are either married or you are not married. If you are married to someone else, you cannot marry this intending immigrant.
If you are a US citizen, your marriage to an alien who came into the US with inspection but overstayed his authorized stay may be a basis to waive his overstay. The overstay of the holders on only certain types of visas is waived upon marriage with a US citizen.
If he is in some sort of removal proceedings, his marriage to you now likely will not help him. Similarly, if he has a visa that does not allow adjustment of status while remaining in the US, the marriage will not help.
Your best option may be to review your facts and options with your attorney