Search for neutrino counterparts of gravitational-wave events detected by LIGO and Virgo during run O2 with the ANTARES telescope