Note that shall and should used in this way are a bit old-fashioned.
Let's start of with a simple conditional,
If John lies to me, I will no longer talk to him
The first verb is present tense and the the second is in the future tense. This is a general truth about a situation that could happen: if John ever lies to you, that's what will happen in the future.
If John shall lie to me, I will no longer talk to him
This rather old-fashioned sentence means that, if at some time in the future John does lie to you, and this is a situation that could happen, you will not speak to him from that moment on.
If John should lie to me, I would no longer talk to him
If you want to talk about a hypothetical situation, you backshift the tenses of both verbs: shall becomes should and will becomes would. This sentence therefore means that, in the unlikely event that John lies to you at some time in the future, you will not speak to him from that moment on.
For a hypothetical situation, you have to backshift both verbs. Your first sentence is therefore correct: the second sentence is not, because should is backshifted and will is not.
Neither of your sentences makes it clear that you have given the cake to John.
The usual options would be:
That is the only cake I could give (to) John.
This is making it clear that you might give this cake to John but that you have NOT done so.
Alternatively, if the dog had eaten the cake, you might say:
That was the only cake that I could have given (to) John.
The cake no longer exists and John certainly didn't get it.
To make it clear that John actually received the only cake you possessed, you would have to rephrase the sentence:
I gave John the only cake I had.
The only cake I had I gave to John.
The only cake I had was the one I gave to John.
or something similar.
Best Answer
In a comment, you said that you knew that "could" is the past tense of "can" and therefore, this is irrelevant to the question.
With the way the question was asked, no context was given, so therefore the comments given were not irrelevant as they are stating facts.
You need to write the question in a way which is clear to others what you are asking in order to get the answer you need.
In the same comment you said
Now, when you are making a rhetorical question, you are not actually asking a question. You are talking to the other person (or people) with the aim to produce an effect or to make a statement rather than to elicit information.
A rhetorical question can be expressed in terms intended to persuade or to impress the importance of a "fact", so therefore, rhetorics can be used in the irrealis mood, as you can have a subjunctive mood,
jussive or imperative moods
as well as other moods in them.
So in answer to your question, the following is used in their relevant ways.
Past tense
Present tense
Rhetorical
You can use either of the two statements but with emphasis on the word can and my neck
Or with emphasis on the words could and my neck with the most effect possible given in the future tense