First of all, you need to know that können has two main meanings in German, which behave somewhat weird in respect to the subjunctive II (Konjunktiv II) and the past:
to be able to, to have the opportunity to – when meaning this, the subjunctive II can behave as with other verbs, i.e., expresses that something is not factual or politeness, e.g.,:
Hätte ich es in der Schule gelernt, könnte ich heute schwimmen.
(If I had learnt it in school, I would be able to swim today.)
Here, you can not replace könnte with the indicative mood kann.
However, there also is some moderately weird usage of the subjunctive (see below).
to possibly be – when meaning this, the indicative mood can always be replaced with the subjunctive II without an effect on meaning¹. For example the following two examples are interchangable:
Das kann sein.
Das könnte sein.
(That could be true.)
Also, when meaning this, the können is always used in the present tense.
Ich könnte es gestern gemacht haben.
means something along the lines of:
It’s possible that I did this yesterday.
This is equivalent to:
Ich kann es gestern gemacht haben.
However, it is unusual to use a construction like this in the first person singular as in most cases you know whether you did it™ and thus can be more informative by saying one of the following:
Ich habe es gestern gemacht.
Ich habe es gestern nicht gemacht.
Except from this, you could use this phrase to taunt somebody (“I could have done it but I do not tell you whether I actually did.”) or comedically (“I am able to have done it.”).
Ich hätte es gestern machen können.
In the more regular and easier-to-understand meaning of this, there is some implied (but unuttered), unfulfilled condition:
Ich hätte es gestern machen können [wenn die Umstände es erlaubt hätten].
(I could have done it yesterday [if circumstances had allowed for it].)
This usually implies that there are some other conditions for you doing it that were fulfilled. For example, you can only do it™ if it is Friday the 13th, your mother-in-law is visiting, the neighbour’s dog is sick and it isn’t raining. Now except for the weather, all these conditions are met. So you could do it™, if it weren’t for the weather and thus you could say:
Ich hätte es gestern machen können. Unglücklicherweise regnete es.
(I could have done it yesterday. Unfortunately, it rained.)
The second meaning is something along the lines of:
I had the opportunity/ability to do it yesterday, but I did not do it.
If you so wish you can interprete this in the sense of the first meaning by inserting some implied internal condition:
Ich hätte es gestern machen können [wenn mein innerer Schweinehund mich nicht davon abgehalten hätte].
(I could have done it yesterday [if my inner demons had not prevented me].)
I would not know of a better explanation of the subjunctive II here that is in accordance to its normal functions. Note in particular that using the subjunctive II like this only works for verbs which indicate ability and opportunity, such as können, in der Lage sein, dürfen, die Möglichkeit haben.
Another linguistic or historic explanation of this usage would be that the subjunctive applies to the modulated verb instead of the modular verb, but again this is not translatable to other cases, e.g., Ich hätte ihn kommen sehen does not imply that he did not come.
That you actually didn’t do it is the only difference from the indicative:
I konnte es gestern tun.
¹ Though some argue that the subjunctive II conveys a lower chance of truthfulness than the indicative mood, i.e., if I say “Das Auto könnte gelb sein”, this conveys a smaller probability of the car actually being yellow than “Das Auto kann gelb sein”.