I wish to expose a custom service API (Soap/Rest) from marketing cloud so that when an external entity invokes the same, I can have some logic to process the data from the request and then return the result to the external entity. Is there any way to do this in SFMC?
I'd recommend creating a CloudPage 'Code Resource' with a JSON Content Type, then use an available server-side language (e.g AMPscript or SSJS) to parse the incoming request, action any events, then return a response.
I typically use AMPscript in my code resource pages and make an external POST request to the endpoint with key/value pairs as x-www-form-urlencoded data, then use the QueryParameter AMPscript function to parse them and return a response to the page (as a json object).
Note, as you are using a Code Resource, it won't be counted as a super message (from a billing perspective).