How to make custom field that value would be calculated as a total of subtasks`s field value?

Is it possible to make a custom field the same as the “cost” field: so that for each task the value of this field is automatically calculated based on subtasks?

No, this is not supported for custom fields, sorry.