Yes you can. Almost every school has a procedure for taking a test or convincing a professor that you have the knowledge the class provides. You still pay the cost of the course, but do not actually attend it.
Getting my degree many, many years after entering the field, I skipped a huge swath of undergrad classes this way. Stuff like non-computer related classes was all that I needed to do 'in person'.
In other words, I skipped 'pressing buttons' for a large chunk of time due to fact that I knew the material and could prove it.
The main difference to the above being that the school recognized that it was possible for a student to understand the core material completely without taking the class, and the above rules do not admit that possibility.