You can. Passport validity of 6 months from the date of entry is recommended for Thailand. (If it were mandatory I think they would say that.)
****************************************************************************************************************************
After entering Thailand I would apply for a passport by mail via the US Embassy Bangkok. I just received my new US passport by mail this past week, about two weeks after I applied. All is done by mail. A very efficient process. You basically get expedited service in Thailand for free and you are not charged an execution fee (acceptance fee) of $35 as you would in the US. You do have to pay postage. About 40 baht for mailing your passport application to US Embassy Bangkok and 100 baht to receive the passport back using Thai Post EMS.
Just a recommendation: you might want to get your passport photo taken in the US. You can certainly have it done in Thailand but you need to make sure they do it in the proper format for a US passport and not the usual size for Thai immigration. They are not the same.