Automation is the preferred option. Many apps are available. I prefer using MacroDroid , since it is free (upto 5 macros) and easy to learn. To understand how MacroDroid works and required settings, my answer here
Edit: I overlooked a correct set of actions, my fault. The earlier option of set ringtone reacts at the point where the phone rings, at which point the phone has already started ringing - deleted that option. Sorry for that
What you could do is reduce the ringer volume to zero, increase the music volume and use the play sound action on the music stream for unknown callers with the incoming call trigger.
And add a corresponding macro to reverse the ringer volume for any caller other than unknown
Your macros would look like this
- Unknown caller macro (name of macro )
Trigger: Call incoming → Select contact →Unknown Caller
Actions:
Volume Change →
Select Ringer (check the box) and set Volume to zero using the sliding scale
Select Music (check the box) and set Volume to say 80 using the sliding scale ( can be adjusted to comfortable level later )
Click OK
Play Stop/Sound →
Choose Sound - The problem with choosing a sound option from the app choices is that it plays only for a short time and you may miss it (optionally you could repeat this action multiple times, having a wait X seconds between these actions-without wait, they would all play nearly at same time)
(OR)
Choose File - You can save a sound clipping of your choice and length on your phone, say in your internal memory and navigate to it by /storage /sdcard0 /soundfile_saved location
.
Click OK
Constraints: None
- Reverse for other callers macro ( for reverting to existing setup for other callers, meaning those who haven't blocked caller ID)
Trigger: Call incoming → Select contact →Any number ( By specifying this, it is applicable to contacts and non-contacts who haven't barred their caller ID )
Only one action in this macro is that of Volume Change as above but with opposite settings of muting music and reverting ringer to original
Constraints: None
Note
For reverting the changes made in the first macro, we have two options:
a) Reverting after a time period of choice
b) Reverting based on caller identity
Second option is chosen and implemented since time based option can produce unwanted results like successive caller ID barred calls, with the second one ( if ) outside the time limit would be wrongly treated
Since I cannot verify with blocked ID calls (not being allowed in my country ), I set the first macro for known mobile contact (and predefined sound instead of saved clip ) and second macro for known landline and it worked. Do let me know if any clarifications or problems arise
Edit: I am running KitKat and you are on Lollipop. There is a difference in how sounds are treated (example below)
Google Voice Recognition functionality that creates the "ding" sound when activated was streamed as notification stream in KitKat. In Lollipop this is switched to music stream.
Source: https://stackoverflow.com/questions/21701432/continues-speech-recognition-beep-sound-after-google-search-update
I am not aware if Ringer sounds also changed, though unlikely. If the macros don't work because of such a change, you may need to change system sounds option similar to music in both macro actions