It's like divorce. Yes, you can, and it happens everyday. But people do not go through divorce simply because there is a better offer.
If it is that simple, then signing on the piece of paper means nothing.
Accepting an offer with your signature means that you promise to come. You should honor your promise to the extent possible. Companies generally do not sue people who break a promise, yet the chance of getting another offer from that company in the future is gone. In other words, you burn the bridge. If you are in a smaller field where people often know one another, you should think very carefully before you break your promise.
It may be better to state that you have another offer and try to get the company to match the offer.