A federal judge is forcing Exxon Mobil to walk away from a lawsuit it filed against an activist investor—a case some shareholder-rights advocates had blasted as bullying.