You can make it in one layer without any script and an additional layer for visualization purpose.
Open "Layer Styling" (F7)
Click plus button to add a new symbol layer
Select the first symbol layer
Set Symbol layer type to Centroid Fill
If you want to extract the centroid as a new file, you can use centroid tool from Processing toolbox -> Vector geometry -> Centroids or from Vector toolbar menu -> Geometry Tools -> Centroids
Run the tool and your will get the centroid of each polygon