Factory reset should delete all the contents on your phone.
If you are really concerned about your IMEI address being tied to your ID then you have 2 options:
Change the IMEI of your phone (not all phones can this be done), it basically consists of rooting your phone and changing ‘repairing’ the IMEI with another IMEI adress with specialized software (you need to look hard but it’s there, and sometimes a pain in the ass). After that you unroot your phone and install stock android on it.
If changing your IMEI isnt for you then destroy your phone and dont sell it, it all depends on your threat model.