Ok. As mentioned in linked post there is 2 solutions I would suggest. Based on your experience and laziness.
Firs one and it's simplest one. Instead of material have a prefab entity with simple quad mesh (even default one will be fine), and have this entity as child to your objects that should show health bar (as mentioned earlier transform hierarchy cost) or have them in world space and just have "reference" to their owner entity (unit for example) and just "follow" them (cost of this additional system but a bit less than transform system hierarchy cost). In this case what you need is simple component for controlling your health bar:
[MaterialProperty("_HealthBarData"), Serializable]
public struct HealthBarData: IComponentData
{
public float4 Value;
}
And in these 4 floats you can encode everything - current health (mostly percentage if you don't want to spent 2 values for current and max health), second float you can use for some effect (like if it is > 0, health bar should pulsate and flash some color, for example when damage taken you set cooldown to this float and reduce it for some seconds and all this time health bar flashing), etc. In simple case this component will be just one float with health percentage.
Then you should have your billboard shader where you draw your quad as actual health bar rectangle faced to the camera. And then you just access _HealthBarData in your code, it can be vertex function or in fragment.
CBUFFER_START(UnityPerMaterial)
float4 _HealthBarData;
CBUFFER_END
#ifdef UNITY_DOTS_INSTANCING_ENABLED
UNITY_DOTS_INSTANCING_START(MaterialPropertyMetadata)
UNITY_DOTS_INSTANCED_PROP(float4, _HealthBarData)
UNITY_DOTS_INSTANCING_END(MaterialPropertyMetadata)
#define _Prop UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4 , _HealthBarData)
#endif
half4 Fragment(FragmentInput input) : SV_TARGET
{
half4 backColor = SAMPLE_TEXTURE2D_X(_BackTex, sampler_BackTex, uv) * _BackColor;
half4 fillColor = SAMPLE_TEXTURE2D_X(_FillTex, sampler_FillTex, uv) * _FillColor;
half4 result = IN.uv.x < _HealthBarData.x ? fillColor : backColor;
return result;
}
Second solution is a bit harder. You have system which gather entities health bar data, then you have ComputeBuffer/GraphicsBuffer which populated by data from entities, in the end this is similar to first approach where you populate health percent value, but in addition you need to populate world space position for your health bar and in the end call Graphics.DrawProcedural (Graphics.RenderPrimitives in latest Unity versions). In shader you do literally the same as in first step, except you need to use StructuredBuffer/ByteAddressBuffer for accessing your data populated on CPU side. And in vertex shader you should reconstruct your quad based on SV_VertexId semantic. (If you don't want to procedurally generate mesh in vertex function you can use Graphics.RenderMeshInstanced but that's has 1023 instances per call limitation and will introduce more useless code.)