There is a possibility of using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer....
Let's assume there is a point layer called 'points_in_polygon', see the image below.

With the following query, it is possible to calculate the number of other points within x distance, and for that information to be in the attribute table.
SELECT p1.*, COUNT(p2.id) AS WITHIN50
FROM "points_in_polygon" AS p1
LEFT JOIN "points_in_polygon" AS p2 ON
NOT ST_Equals(p1.geometry, p2.geometry)
AND ST_Distance(p1.geometry, p2.geometry) <= 50 -- this value can be changed
GROUP BY p1.id
It encapsulates two functions i.e. ST_Distance and ST_Equals.
Unfortunatelly the ST_DWithin function is not implemented in Virtual Layers, however, another solution will be available through the SpatialLite PtDistWithin function, as was suggested by @BERA.
SELECT p1.*, COUNT(p2.id) AS WITHIN50
FROM "points_in_polygon" AS p1
LEFT JOIN "points_in_polygon" AS p2 ON
NOT ST_Equals(p1.geometry, p2.geometry)
AND PtDistWithin(p1.geometry, p2.geometry, 50.0) -- this value can be changed
GROUP BY p1.id
In both cases, the output point layer with its attribute table will look like:

Note: More sophisticated solutions can be performed using the PostGIS, see the first reference.
References:
QgsFeatureRequest.setDistanceWithin– Kalak Oct 19 '23 at 06:44heatmap kernel density estimationand add the density data back to your points. – Erik Oct 19 '23 at 07:29