1. In principle, yes, but not all immigrations offices may agree to do it.
2. Where an immigration office agrees to do it, you need to coordinate it with the school where you plan to study, as this school will have to provide you with certain documents to submit with your application for the non-immigrant visa category ED (non-ED visa, for short)
The Triple A Language School (AAA) has detailed information about the procedure on the web page
https://www.aaathai.school/17541916/at-the-immigration-in-bangkok#:~:text=- Special tourist visa (STV),and apply for visa extension.
I don't know when this information was written by this school and if the same procedure still applies today. Presumably, other qualifying schools have similar procedures.