1. I could have come in time yesterday.

2. I could come in time yesterday.
(What is the difference between them?)

3. I have done it.
4. I could do it.
5. I could have done it.
6. I couldn't do it.
7. I could not have done it.
(What is the difference between them? #5 mean I didn't do it. #7: I did it. Is that right?)

1 is fine -- and it's expressing a past possibility.

2 doesn't make sense because "yesterday" indicates the past, but the inference is in the future.

3 is a fact. It's done!

4 and 5 are possibilities, one present and one past.
6 and 7 are negative possibilities, one present and one past.