Can a intramuscular injection be given subcutaneously and still work?

Perhaps, but depends. Each medication, or parenteral drug or testing such as a tuberculin test has a different purpose and different absorption characteristics. So some have to be given in the muscle and some within the skin layers. So follow the instructions of the manufacturer of the product.