Is there any machine learning algorithm that can solve this problem?
You want a supervised approach. Clustering will not care about your target variable and perform arbitrary splits that don't help.

Likely a decision tree can be helpful here, if you use a good implementation that can split the same feature multiple times (to break it into intervals). There are other approaches you could try, such as piecewise regression etc.