Is it possible to use an internal layer's outputs in a loss function?
Yes, you can do that, and it is a standard practice. One famous example is the &quot;Inception&quot; network architecture. To keep inner subnets from &quot;dying out&quot;,  several outputs from inner layers are extracted and passed into FC-&gt;Softmax. Then all the outputs are averaged in the loss function.
From practical point of view, you won't be able to implement such things with basic Sequential model construction. Most libraries allow you to move beyond it, though, and this distinction is usually well-documented. For example in the tensorflow guide on functional API it states right in the introduction:

The functional API is a way to create models that are more flexible than the tf.keras.Sequential API. The functional API can handle models with non-linear topology, shared layers, and even multiple inputs or outputs.

Hope that'll help you to get started.