Can I take a course and get credits without enrolling in a program in the US?
This is possible at many universities. You will have to check with them about enrolling as a non-matriculated student. There will almost always be a charge for tuition, but you can enroll (many places) as a student and get a grade. It is also possible in many places to enroll for non-credit, but you probably want the "credit" option. 

Whether a university back home will accept them or not is up to them and not guaranteed, but, again, many universities are willing to do this for a limited number of credits. It might be best to check there as well so you avoid surprises.