A Long Island pharmacy cannot be held liable for dispensing opioid and other medications as part of a medical malpractice lawsuit, a Suffolk County judge ruled Wednesday.