All of the example sentences given are grammatically correct and have similar meanings but differ in the time tense they imply.
1) I would like to ask you a question:
2) I would like to have asked you a question:
3) I would have liked to ask you a question:
4) I would have liked to have asked you a question.
#1 says you have a wish (in the present) to ask a question (sometime in the future).
#2 says that you (in the present time) still wish you had asked the question (in the past).
"I would like to" implies some future action you want to do.
"I would have liked to" implies some action you wished you had done in the past.
Both #3 & #4 have almost identical meanings (most people wouldn't notice the difference in meaning between them). They both have the meaning that (in the past) you wish that you had (in the past) asked the question.
Unfortunately, English doesn't handle time tenses very clearly. To explain the difference between #3 and #4 I am going to create a timeline:
A1=time you first regretted not asking question
A2=any time between A1 and A3 when you regretted not asking
A3=Now (when you make the statement).
A4=Future (from when you make the statement).
Statement #1 is you at A3 talking about A4.
Statement #2 is you at A3 talking about A1.
Statement #3 is you at A3 talking about A2.
Statement #4 is you at A3 talking about (A2 when you were thinking of A1).
"Have" or "Had" implies something in the past, "has" or "is" implies something in the present and "would", "will have", or "will be" implies the future.