You can totally do this, but there is a huge amount to consider.
Creating and removing indexers should not be done lightly - depending on your configuration, there is huge potential to loose data irretrievably, and/or render your entire deployment unrecoverable.
With that said, if you are using S2, this becomes significantly more achievable, but the scale down process still needs a number of things to run first to roll off hot buckets to S2.
I suppose at this stage, its worth asking the question:
Is this for a test/dev/lab environment (where you don't care about the data) or is this Prod and you need to preserve the data?
If its the latter, I very strongly suggest you engage with Splunk PS and take their guidance, as there is a lot to think about.
Its right now for a test purpose .
for say : deleting the indexer from splunk below three steps should be prcoessed but as said earlier i'm new to scripting it would be grace if you can help me out with this:
#!/usr/bin/env bash
/opt/splunk/bin ./splunk stop
./splunk clean eventdata -index indexname
./splunk start