Here is a link to a video which shows how to remove (so you can replace) the SIM card reader in your phone. You can see the SIM card reader being removed right at the end of the video (3:45 minutes)
Here is a link to a supplier of the part. It is not a recommendation to use the seller, it is shown to give an idea of the price. There may be other suppliers that may suit you better. Just search online for HTC One M8 SIM card reader part for results.
If you find the repair process too daunting, contact a reputable, professional mobile phone repair service and ask for a quote to repair the phone. (At least you will already have an idea of the cost of the replacement part).