Yes, use malloc
to place the integer in heap memory and obtain a pointer. You can then return this pointer from the function:
int* sum(int *mypt, int len) {
int i;
int* mysum = malloc(sizeof(int));
//make sure you dereference (*) when you wish to work with the value.
*mysum = 0;
for(i=0; i<len; i++) *mysum += *mysum;
return mysum;
}
Aside, it looks like a lot of your code is broken. This only solves how to return the pointer!