The McArthur family, who run Ashers Baking Company in Belfast, are trying to overturn a court judgement that they acted unlawfully on sexual orientation grounds.
Their appeal began on Monday.
The couple said this case has implications for freedom of expression across the UK.
Family barrister David Scoffield QC said: "They could not in conscience provide a product with a message that was inconsistent with their deeply-held religious beliefs in circumstances where the evidence was clear that they believed that to do so would be sinful."
Last year Ashers' owners were ordered to pay £500 in damages after a County Court judge ruled they directly discriminated against Gareth Lee when they refused to make him a cake featuring Sesame Street puppets Bert and Ernie with the phrase "Support Gay Marriage."
Mr Lee paid £36.50 at Ashers' Belfast city centre branch, but received a phone call two days later and was told the company could not fulfil his order.
Mr Scoffield represented the McArthurs at Belfast's Court of Appeal and said the person who took the order had no idea what Mr Lee's sexual orientation was.
He said the alleged discrimination was not against Mr Lee, but was against the message, but the law only covered harm caused to an individual.
Mr Scoffield said: "Discrimination must be against the person, not against an idea or an object.
"A cake cannot have a political opinion or a religious belief, it is a person who can do so."
He added: "It makes it extremely difficult for any business such as a printer or someone who, as we have seen in this case, creates T-shirts or creates cakes, to run any kind of bespoke service if faced with the position that someone could come through your door and order something which is clearly objectionable."
The hearing continues and will hear submissions from a lawyer for Mr Lee.