Is there a way to bind a texture id to a sampler2D uniform of a shader?
No, not really, because samplers access texture units, not texture objects. However NVidia's Kepler GPUs can use bindless textures, available to OpenGL as a vendor specific extension, which practically implement what you ask for.