Yes, it's possible. Be sure not to use any compute capability 5.0+ specific features in your code, and you should be able to run your code properly on either a cc3.7 device or a cc5.0 device.
When compiling your codes, specify target architectures for both compute capabilities, e.g.
-gencode arch=compute_50,code=sm_50 -gencode arch=compute_37,code=sm_37
and such a compilation method should be usable on either platform to create a usable binary. Furthermore, compiling that way will cause the compiler to flag any situations where you may have inadvertently used a cc5.0+ specific feature.
I think it's unlikely that you would inadvertently use a cc5.0+ specific feature; they wouldn't be part of common CUDA usage. As an example, if you attempted to use the lop3.b32
instruction in inline PTX, that would not work on a cc3.7 device (and using the above compile switches, the compiler would flag that for you.)