Yes, an optometrist can prescribe medication, but this scope of their practice is limited. Optometrists are licensed to prescribe:
Medications for eye infections
Anti-inflammatory drugs
Eye drops for glaucoma
Antibiotics and antiviral medications for eye-related conditions