I think what you're looking for is "validation rule" more than formula. It's true that the trigger of the validation rule is usually a formula :)
Validation rule reject record update and display an error message when formula is evaluated to true. So we have to make sure that the formula is giving true if the value of the field is "Apple" and the profile of the user making the change is neither "Apple Profile" or "Melon Profile".
Translated to formulate is:
ISPICKVAL(Stage__c , "Apple"),
NOT($Profile.Name = "Apple Profile"),
NOT($Profile.Name = "Melon Profile")
For the second need (only Apple on creation), you must ensure two or three things:
- Do you need a different error message (I advise to have two different to make it explicit)
- Does the two VR collide, usually we use the
PRIORVALUE(field) to detect creation / modification
As a side note, I forgot to mention that a better design here would be to use either a custom permission or a hierarchical custom settings
- Custom permission will allow you to block / enable users based on the profile and/or permission set assigned to it
- Custom settings will allow you to block / enable users based on the profile or particular user
They both work, probably using a custom permission is better as functionally it is a permission to change or not the value. And this could allow 3 levels or assignment, profile, permission set group, permission set. Salesforce also encourage us to move to permission set.