How to apply ILM to ML indices? If not possible what,s the workaround?

Understand that ILM cannot be used on ML results indices. ILM is used on the ML state index out-of-the-box.

Seems like this is a long open enhancement.
[ML] Add an ML results index rollover endpoint · Issue #29946 · elastic/elasticsearch · GitHub

The size of each ML results index can be kept down by using a custom index per job instead of the shared results index.

Could anyone guide us with example on how we can do that?

See the API documentation: Create an anomaly detection job | Elasticsearch API documentation

See:

  • results_index_name
  • results_retention_days