The legal position is this. You have accepted an offer to start employment so that stands. Within your contract will be a term that allows you or the employer to terminate that contract giving notice. If it isn't mentioned in the contract then statatory provisions apply but in your career position I am sure something will be referred to (often one month's notice either way, but may be more). So the employer can ask you to deliver to the contract but on the first day you could resign and give the notice period.
Now any sensible employer if you approach them now citing a change of circumstances will just drop the whole recruitment. They won't like you for it, but unless you work in a close industry where everyone knows everyone else's business and personnel, what the hell? What comeback can there be for you?
Yes, I have done it - early in my career before I later became a Personnel professional who understood these things better. I accepted a new job then got a far better offer 3 days later, so told them I wouldn't be joining. Felt real bad about messing them about at the time.