Yes, you can definitely do this. Many schools will allow you to enroll as a non-degree student and take whatever classes you want for credit. (Definitely any public university or community college and many private schools as well, if they have a school of continuing education or something like that.)
I would check with School X, though, and make sure that they accept online classes for prereqs. Some schools do, some schools don't. Taking it during the summer shouldn't be a problem as long as you take it for credit. It's also a good idea to have a back up plan in case you're unable to register for the class you want at a given school. For example, I know that some classes fill up insanely quickly at the CC in my area and registration preference is given to degree-seeking students first.