You can, assuming your undergrad school finishes before med school starts. Some people have to in order to finish their degree or finish classes to honor their acceptance (because they told the school they'd be in classes, usually a prereq).
That being said, if it's possible to not, don't. Relax during that summer because med school hits like a freight train and you want to be well rested and relaxed.
the issue actually when the deadline for completion of required courses is for medical school where you will be matriculating. Medical schools are beginning earlier and earlier in the summer. Some schools are requiring required prereqs be completed as early as January of matriculatiom year. Additionally, these courses must be officially reported on transcripts in order to be acceptable by schools. I have seen a few cases where summer work was done by acceptee but was not reported on transcripts in time and acceptee was deferred (some schools are this way). Lastly, you also to make sure that you are in compliance with your matriculation agreement for such things as completion of educational program. That is if you take a summer course and dont file for UG graduation/degree until the course is done. this may push your degree award after med school matriculation date which can also be an issue.