Yes, the entropy of a password generated with a truly secure random source for P would be
E = log2(P^L)
However, you said that you are "randomly" generating a password but you did not specify how the random value would be generated. And therein lies the real risk.
Mathematical random number generators aren't actually random. They are just math formulas that are created with the intent of producing numbers that are statistically evenly distributed, but there is no attempt to make them unguessable. They are more properly known as Pseudo-Random Number Generators (PRNGs). These algorithms are initialized with a value called the seed, and each time they are called they return a different number, producing a stream of values. If the seed value is repeated, the stream of numbers generated will be repeated. This is very useful for re-running simulations with the same statistically random data, but it is not good for security. If an attacker guesses the seed value, they would know all the passwords that were generated. And if an attacker sees a sequence of random numbers produced by the algorithm, they can use the sequence to compute the internal state of the algorithm, and recover the seed.
For security purposes, random numbers need an additional property, and that is to be unguessable. This means using a special type of random number generator called a Cryptograhpically Secure Pseudo-Random Number Generator (CS-PRNG), and a better initial source of entropy than a static seed value.
If you use a simple PRNG to generate your passwords, they will have literally no entropy and will be vulnerable to an attacker who understands them. However, if you use a good quality CS-PRNG, they'll actually be secure, and then you can compute entropy.