There are two bars that such evidence would have to clear: admissability and believability. As established in Brown v. Mississippi, the police cannot beat a confession out of you: any such statement cannot be entered as evidence. There are numerous procedural requirements on statements obtained by the police, such as the famous case of Miranda v. Arizona which requires police to inform a person in custody of their relevant rights. Wire-tapping laws exist at the federal level as well as the state level – some state versions are more stringent, and such laws may make such a confession inadmissible in court. Also inadmissible is "heresay"; there are various circumstances where it is allowed to introduce as evidence testimony like "I heard Bob say that Lou bragged about murdering Sal", and a concept of "adoptive admission" which has the consequence that if you don't protest an accusation or wrongdoing, that is the same as confessing to doing it (jurors still have to decide if they believe it, but it is admissible).
If a statement is admitted as evidence, then the jury has to decide whether they believe the statement. Assuming you are being tried by a jury, for the most part it depends on whether the jurors believe the statement. The basic premise is that anyone who makes a statement, especially to the police (and especially writes it down and signs it) has thought about the statement, understands it, and is telling the truth. It is not impossible to try to defend yourself by claiming that you didn't understand the statement you were signing, but that's an uphill battle.
Suppose on the one hand during an interrogation, the police ask "Have you seen Smith since Friday?" and you stupidly say "Yeah, I shot him on Monday. Of course not you idiot, I already told you, I haven't seen Smith for over a year". The first sentence taken out of context could be interpreted as an admission, but with the full context it's clear that it is not: it's a dangerous smart-mouthed childish outburst. But if you carefully write out details of the murder, the jury would very likely interpret the statement as true. (Actually, lying may be illegal, depending on who you are lying to: see 8 USC 1001). Once the accused confesses to something, it is incumbent on him to prove that his statement cannot be believed.
There is no legal standard of what constitutes being believable, so to "help" jurors, the judge may read instructions along the following lines (Calcrim instructions, 2006 version)
You alone, must judge the credibility or believability of the
witnesses. In deciding whether testimony is true and accurate, use
your common sense and experience. You must judge the testimony of each
witness by the same standards, setting aside any bias or prejudice you
may have. You may believe all, part, or none of any witness’s
testimony. Consider the testimony of each witness and decide how much
of it you believe. In evaluating a witness’s testimony, you may
consider anything that reasonably tends to prove or disprove the truth
or accuracy of that testimony. Among the factors that you may consider
• How well could the witness see, hear, or otherwise perceive the
things about which the witness testified?
• How well was the witness able to remember and describe what
• What was the witness’s behavior while testifying?
• Did the witness understand the questions and answer them directly?
• Was the witness’s testimony influenced by a factor such as bias or
prejudice, a personal relationship with someone involved in the case,
or a personal interest in how the case is decided?
• What was the witness’s attitude about the case or about testifying?
• Did the witness make a statement in the past that is consistent or
inconsistent with his or her testimony?
• How reasonable is the testimony when you consider all the other
evidence in the case?
• [Did other evidence prove or disprove any fact about which the
• [Did the witness admit to being untruthful?]
• [What is the witness’s character for truthfulness?]
• [Has the witness been convicted of a felony?]
• [Has the witness engaged in [other] conduct that reflects on his or
• [Was the witness promised immunity or leniency in exchange for his
or her testimony?]
Do not automatically reject testimony just because of inconsistencies
or conflicts. Consider whether the differences are important or not.
People sometimes honestly forget things or make mistakes about what
they remember. Also, two people may witness the same event yet see or
hear it differently. [If the evidence establishes that a witness’s
character for truthfulness has not been discussed among the people who
know him or her, you may conclude from the lack of discussion that the
witness’s character for truthfulness is good.] [If you do not believe
a witness’s testimony that he or she no longer remembers something,
that testimony is inconsistent with the witness’s earlier statement on
that subject.] [If you decide that a witness deliberately lied about
something significant in this case, you should consider not believing
anything that witness says. Or, if you think the witness lied about
some things, but told the truth about others, you may simply accept
the part that you think is true and ignore the rest.]
The shorter version is "use your common sense". The problem with this level of detail about what might influence a judgment of believability is that it encourages people to think that any factor not mentioned should not be considered (after all, the judge didn't say "or anything else that you think reasonably bears on believability").