He could have told her at some point, it doesn't have to be the wedding night. There were x amount of years, after all.
And what promise to his sister? She did not ask him to keep the baby's identity secret, only to keep the baby safe. Again, if he wasn't a twat, he'd have told Cat, so she wouldn't have treated Jon like shit.
As Lyanna lies dying after childbirth, she whispers this to Ned: "If Robert finds out, he'll kill him, you know he will. You have to protect him. Promise me, Ned. Promise me." The "Robert" she speaks of is Robert Baratheon - to whom she was originally betrothed - and is now the King of Westeros (since Ned and Robert have just defeated her real love, Rhaegar Targayen, on the battlefield). Rhaegar stole her heart from Robert - setting off the uprising known as Robert's Rebellion and leading to the events of A Game of Thrones.
Since Jon Snow is a Targaryen, he is a threat to any ruler who sits on the Iron Throne, and even has precedence over his aunt, Daenerys Targaryen - who Robert still wanted dead 15 or so years later - despite her being only a powerless child at that time... So even Ned's allies would want Jon, a Targaryen, dead.
Given what Ned and his family had been through, the lay of the land at the time, followed the surprising encounter with his sister on her deathbed - he came up with a plan which seemed to make the best of the situation he could at the time - of course, not ideal. He could have told Catelyn years later after they had grown to love each other - but why risk Jon's life and that of his family and even the kingdom - in another long and bloody war - if that had somehow slipped out?
One man's 'shame' in people thinking he fathered a bastard - and one woman's scorn towards Jon for being that bastard (and in doing so deflected away questions of Jon's true parentage) - was the price Ned probably thought was worth it.
So Ned is hardly being 'a twat' here - as promised to Lyanna - he is keeping Jon safe as he can...