<<Converting the information from comments to here for broader community usage>>
Thank you @Amol Pawar for your query.
Came across a similar case notes I could find below information , which I thought would help our community members having similar issue. So sharing it here.
If you are performing an app-only auth, which results the above error. Which is by design.
However to modify the attributes, you need to use PowerShell or perform a User auth to acquire a token.
Hope the above information helps for other community members facing this issue. Thank you